Important: Please read the Qt Code of Conduct -

QTextCurser WordUnderCursor does not return word

  • Hi,

    I am working from the examples/tools/customcompleter. I removed the eow check to allow for a completion when I am within brackets or quotes. Unfortunately the function textUnderCursor() does not return the word when I am in a bracket or quote.




    in stead of


    If there is a space before the second quote the returned value is as expected erro. So how can I change the textUnderCurser function to get the word when the curser is between a letter and a quote?

    QString CodeEditor::textUnderCursor() const{
        QTextCursor tc = textCursor();;
        QString mText = tc.selectedText();

    I already tried around with moving the curser but this did not help.

    By the way, I do have the same issue in Creator with custom functions that require a variable.

    void myFunction(QString currentText);

    If I call this function and want to hand over a variable name, the completer is not popping up.

    QString lastText = "Some Text";
    myFunction(lastT|) // No completer showing up

Log in to reply