I have my custom implementation of QAbstractTableModel and of QSortFilterProxyModel, used for filtering. The table is shown in a QTableView.
The parent dialog of my QTableView has a QStatusBar, with a read-only QLineEdit widget.
In my overriding data() method of QAbstractTableModel, I'm setting the pertinent values for the Qt::StatusTipRole role.
Now I'm missing part of the plumbing: how do I get my per-cell StatusTipRole data to show up in my widget inside QStatusBar?
There is no need to override the view widget. Qt provides built-in support to show status tips for items in a model.
Normally, You just need to return a
QStringfrom your model'sdata()whenroleisQStatusTipRole, and thatQStringwill be shown in the status bar when you hover your item.You also need to turn on mouse tracking for the
QTableViewso that you get status bar updates without the mouse button being pressed. This is because when mouse tracking is disabled (by default), the widget receives mouse move events only while a mouse button is pressed.Now, in order to display those status tips in your
QLineEditinstead of the default status bar, You can override your main window'seventfunction, interceptQStatusTipEvents, and show tips in yourQLineEdit.Here is an example implementation: