PDA

View Full Version : Tooltip on QTableWidget header



ghorwin
29th October 2007, 05:22
Hi there,

is there an easy solution to get tooltips when hovering over headers in QTableWidget or QTableView widgets?

My solution would be a combination of QHelpEvent and some coordinate calculation using indexOf() in the QHeaderView to find the correct header/column, but this looks to complicated...

Thanks,
Andreas

wysota
29th October 2007, 09:34
Did you try returning data for Qt::ToolTipRole from within your model in the headerData() method?

jpn
29th October 2007, 09:35
And with QTableWidget you could use header items:


QTableWidgetItem* headerItem = tableWidget->horizontalHeaderItem(0);
if (headerItem)
headerItem->setToolTip("Hello, world!");

wysota
29th October 2007, 10:09
All these of course provided that either the header view or the basic view can handle it. QHeaderView is a very limited class when it comes to model/view features.

jpn
29th October 2007, 10:34
All these of course provided that either the header view or the basic view can handle it. QHeaderView is a very limited class when it comes to model/view features.
Yup, QHeaderView can handle tooltips out of the box.