c++ - Setting a dynamic tooltip for QHeaderView item -


I want to do a dynamic tooltip for one of my header items in a QtableView.

Tooltip changes with content Alt key press I found some code related to using delegates in the following site:

In the same lines I tried the following part of the code: / P>

  Class HeaderToolTipDelegate: Public QStyledItemDelegate {Q_OBJECT Public: HeadToolTipDialGate (QObject * inParent); ~ HeaderToolTipDelegate (); Public slot: bool helpEvent (QHelpEvent * inEvent, QAbstractItemView * keeping in mind, constant QStyleOptionViewItem & inOption, constant QModelIndex & amp; inIndex); }; Bool HeaderToolTipDelegate :: helpEvent (QHelpEvent * inEvent, QAbstractItemView * Keeping in mind, constant QStyleOptionViewItem & inOption, constant QModelIndex & inIndex) {if (inEvent = keeping in mind!) Return false; If (inEvent-> gt; type () == QEvent :: ToolTip) {QVariant Tooltip = inInex.data (Qt :: DisplayRole); If (QApplication :: keyboardModifiers () == QT :: AltModifier} {QToolTip :: showText (inEvent-> globalPos (), QString ("AltKeyPressed"), keeping in mind); } Else {QToolTip :: showText (inEvent-> GlobalPos ()), Qestring ("AltKeyNotpressed", invoice); } If the QToolTip :: hideText () (QStyledItemDelegate :: helpEvent (inEvent, keeping in mind, inOption, inIndex)!); Back true; } Return QStyledItemDelegate :: helpEvent (inEvent, inView, inOption, inInex); }  

and then I see headerView horizontalHeader () -> Attempted to set the delegate to setItemDelegate (new header option) . But it does not work.

It seems that the item does not work for Delgate headerwish.

What is the correct way to get it?


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -