Important: Please read the Qt Code of Conduct -

QListWidgetItem's Tool Tip not showing up

  • In my application, I'm using a custom class derived from QStyledItemDelegate to control what is shown for any given item in my QListWidget. Previous developers wrote the loading code for said QListWidget such that all of the loading was done in the main thread, leading to a blocked UI experience. While trying to off-load some of that to a worker thread, I ran across this frustration: if I create the instance of my delegate in the worker thread, then the tool tip no longer displays after the call for QListWidgetItem::setToolTip.

    Has anyone encountered anything like this?

  • For those curious, I did find a solution. Within the worker thread's method that creates the delegate, I had to do delegate->moveToThread(QApplication::instance()->thread()) to change the delegate's thread affinity back to the main thread.

    This is because the tool tip is fired off of the helpEvent slot, which has a return value, and the meta system, when it sees the that the thread affinity between the caller and the target objects are different, will use QueuedConnection, and QueuedConnection does not support return values. Hence, no call to helpEvent and no tooltip being shown.

Log in to reply