Checking then Adding items to QСompleter model <p>I am currently working on a code editor written in Qt,</p> <p>I have managed to implement most of the features which I desire, i.e. auto completion and syntax highlighting but there is one problem which I can't figure out.</p> <p>I have created a model for which the <code>QCompleter</code> uses, which is fine for things like html tags and c++ keywords such as <code>if else</code> etc.</p> <p>But I would like to add variables to the completer as they are entered by the user.</p> <p>So I created an event on the <code>QTextEdit</code> which will get the word (I know I need to check to make sure that it is a variable etc but I just want to get it working for now).</p> <pre><code>void TextEdit::checkWord() { //going to get the previous word and try to do something with it QTextCursor tc = textCursor(); tc.movePosition(QTextCursor::PreviousWord); tc.select(QTextCursor::WordUnderCursor); QString word = tc.selectedText(); //check to see it is in the model } </code></pre> <p>But now I want to work out how to check to see if that word is already in the <code>QCompleter</code>s model and if it isn't how do I add it?</p> <p>I have tried the following:</p> <pre><code>QAbstractItemModel *m = completer-&gt;model(); //dont know what to do with it now :( </code></pre> <p>Any help would be fantastic.</p> <p>Thank you.</p>