Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to implement code completion in qt [closed]

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 ?

like image 896
Radi Avatar asked Mar 19 '10 08:03

Radi


2 Answers

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

like image 154
Tobias Avatar answered Nov 15 '22 02:11

Tobias


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.

like image 23
Barış Akkurt Avatar answered Nov 15 '22 02:11

Barış Akkurt