开发者

how to implement code completion in qt [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
开发者_运维技巧

Want to improve this question? Update the question so it focuses on one problem only by editing this post.

Closed 4 years ago.

Improve this question

i am writing an ide using qt (on c++) and i need to add auto completion feature to it

so i want to know :

how to do that (i am using qtPlainTextEdit) ?

what the data structure i should use ?


I think you should take a look at this:
http://qt-project.org/doc/qt-4.8/tools-customcompleter.html

I used this example to understand CodeCompletion and I think it is fine :)

[edit] Qt has a own class for such purpose called QCompleter: http://qt-project.org/doc/qt-4.8/qcompleter.html


I also need to write a code completer in Qt and the first link Tobias provided is the document to look at. It is comprehensive and clear and worked for me. I am sure will work for you.

If you need a code completer in lineEdit, it's pretty simple (from the QCompleter documentation):

QStringList wordList;
wordList << "one" << "two" << "three" << "four" << "five";
QLineEdit *lineEdit = new QLineEdit(this);

QCompleter *completer = new QCompleter(wordList, this);
lineEdit->setCompleter(completer);

However a QPlainTextEdit, or QTextEdit don't have a built-in setCompleter() member function so you must follow the custom code completer tutorial.


That's a big, complex feature. I'd look at how it's been done in the Qt Creator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜