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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With