Nominate our 2022 Qt Champions!

QComplter with ToolTip

  • Hi,

    I would like to add a tool tip to my completer suggestions. Much like Creator does. First I tried to add a tool tip to my underling completer model:

        QCompleter *completer = new QCompleter(this);
        QStandardItemModel *model = new QStandardItemModel(this);
        model->setItem(0, new QStandardItem("test"));
        model->item(0)->setToolTip("Tool Tip test");

    But the tool tips do not show up.

    I managed to get tool tips with a custom delegate using QToolTip::showText(), see here, but that requires a point in screen coordinates, which I do not have.

    Is it either possible to make the above code work or pass the correct position to the delegate?

    Regarding the second approach. I already tried mapToGlobal but I do not have a widget I could call that on...
    Any help would be much appreciated.

Log in to reply