Unsolved Add tooltips for individual headers
-
@pk23081996 Hi,
You probably need to do this:
myModel.horizontalHeaderItem(0)->setToolTip("Header 0"); myModel.horizontalHeaderItem(1)->setToolTip("Header 1");
-
Hi @Gojir4, My model is subclassed from QAbstractTableModel. The methods you suggested are present in QTableWidget class but I am using QTableView here. Is there any workaround for that? This method is not available in QTableView.
-
-
Are you sure "headerData() for role == Qt::toolTipRole" is not being hit? E.g. https://stackoverflow.com/a/13461087 seems close enough to your case but claims to work?
-
Since
QTableWidget
derives fromQTableView
, in principle if it can be done in the former you can do it too if you derive from the latter. You might want to look at the source code to see if the code is easy to copy for your situation?
-
-
Hi @JonB ,
1.Yes I am sure about it as i tried putting debug statements inside the functions. Only the data() was getting hit.
2.The point is the QTableWidget class uses QTableWidgetItem class which contains the setToolTip function. The QTableView doesn't contain this method.Can you just show me how you want me to do it?
Thanks
-
@pk23081996 said in Add tooltips for individual headers:
Can you just show me how you want me to do it?
Are you using QTableView or a QTableWidget?! In your first post you said QTableView and you also claimed that you subclassed QAbstractTableModel.
This is essential since a QTableWidget has it's own internal model.If its correct that implemented QAbstractTableModel, use QTableView and call setModel() on it. This applies the model to the view itself and also applies it to it's QHeaderView widget. Which definitely calls headerData().
If not show us your code, you maybe have a different signature in your headerData() method, which has the effect that it is not called by the QHeaderView widget.
-
@pk23081996 said in Add tooltips for individual headers:
Hi @Gojir4, My model is subclassed from QAbstractTableModel. The methods you suggested are present in QTableWidget class but I am using QTableView here. Is there any workaround for that? This method is not available in QTableView.
You're right I was on QStandartItemModel doc and not on QAbstractTableModel. My bad sorry.
-
@raven-worx Hi, I don't say it is not hitting headerData() but only not for QToolTipRole.
-
@pk23081996
anything else special about your model/tableview?Heres the corresponding implementation code which requests the data.
-
@raven-worx Ya there is nothing special here, just that the role is not coming out to be ToolTipRole here.
-
This post is deleted! -
This post is deleted!