我正在使用qt编写一个ide(在c ++上),我需要为它添加自动完成功能
所以我想知道:
怎么做(我正在使用qtPlainTextEdit
)?
我应该使用什么数据结构?
答案 0 :(得分:8)
我想你应该看看这个:
http://qt-project.org/doc/qt-4.8/tools-customcompleter.html
我用这个例子来理解CodeCompletion,我认为没问题。)
[编辑] 为了这个目的,Qt有一个名为QCompleter的类:http://qt-project.org/doc/qt-4.8/qcompleter.html
答案 1 :(得分:3)
我还需要在Qt
中编写代码完成者,Tobias提供的第一个链接是要查看的文档。它全面而清晰,为我工作。我相信你会为你工作。
如果你需要在lineEdit中使用代码完成器,那么它非常简单(来自QCompleter文档):
QStringList wordList;
wordList << "one" << "two" << "three" << "four" << "five";
QLineEdit *lineEdit = new QLineEdit(this);
QCompleter *completer = new QCompleter(wordList, this);
lineEdit->setCompleter(completer);
但是,QPlainTextEdit或QTextEdit没有内置的setCompleter()成员函数,因此您必须遵循custom code completer教程。
答案 2 :(得分:1)
这是一个很大的复杂功能。我会看看它是如何在the Qt Creator完成的。