Hi,
Is it possible to display tooltips when hovering over items in the tableview?
Regards,
Steve
Hi,
Is it possible to display tooltips when hovering over items in the tableview?
Regards,
Steve
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
or QAbstractItemModel::setData with Qt::ToolTipRole.
Hi,
setData, would I use this in my custom model? I'm presuming that I can then do a comparison in my data function in my model to see if the role is Qt::ToolTipRole ?
Snippet below :
Qt Code:
{ QVariant data; if( role == Qt::ToolTipRole) // do whateverTo copy to clipboard, switch view to plain text mode
If so, what do I do?
Regards,
Steve
Yes, like that.
From data you return whatever text you want the tooltip to display.
Regards
Thanks,
Ok, but I don't call setData anywhere in my model, I just update the data structures it uses. Will the role be Qt::ToolTipRole at some point or do I need to use setData for this to happen??
Regards,
Steve
The default delegate will ask the model for tooltip. If you return one, it'll display it.
Hi,
I thought this also, but no tooltip is displayed?
In my data method I just did this so I thought the tooltip would be shown as 'Signal', but nothing appears.
Qt Code:
if( role == Qt::ToolTipRole ) { data = "Signal"; }To copy to clipboard, switch view to plain text mode
Regards,
Steve
return "Signal" and not data = "Signal". What is "data" anyway?
Hi,
Sorry wysota, data is QVariant and at the bottom of the function I return data. I set a breakpoint in my data method to break when the role is Qt::ToolTipRole, but it never breaks.
Regards,
Steve
It should if you didn't change the delegate. Could you show us the complete data() method?
Sure, here it is :
Qt Code:
{ QVariant data; if (!index.isValid()) if(index.column() > 4 ) { } if( role == Qt::ToolTipRole ) { data = "Signal"; } if( role == Qt::DisplayRole ) { CDADcb::CSignal* pSignals; pSignals = (CDADcb::CSignal*)theApp->m_dcb.GetSignalList()->at(index.row()); switch( index.column() ) { case SIGNALNAME : { data = pSignals->name; break; } case DATA : { data = pSignals->m_strRawData; break; } case UNIT : { data = pSignals->unit; } break; case COUNT : { data = pSignals->m_nCount; } break; } } return data; }To copy to clipboard, switch view to plain text mode
Regards,
Steve
Bookmarks