The title, the effect for Qtreeview or Qtableview in the case of focus, move the mouse and a short stay, you can eject the ToolTip and display the current mouse pointer to the row of data
There are two different ways to display data that is too long to be hidden:
1, the use of the entire window/view event filter
Suppose the window has a TreeView control with the name
BOOL Mywidget::eventfilter (QObject *editor, qevent *event)
{
if (Event->type () ==qevent::tooltip) {
Qhelpevent *helpevent = static_cast<qhelpevent *> (event); Tooptip Pop-up event to help
qpoint P_top=helpevent->globalpos (); Tooptip display position, global coordinates
qpoint p_view=ui->treeview->mapfromglobal (p_top); Converts the global coordinates of the mouse to the coordinates in the TreeView
qmodelindex Currentindex=ui->treeview->indexat (TMPP); Gets the index
QString name=currentindex.data (Qt::D isplayrole) to which the mouse points. toString ();
Qtooltip::showtext (p_top, name); Show ToolTip return
true;
}
Return Qwidget::eventfilter (editor, event);
}
2, custom model, inherit from Qstandarditemmodel
Under the model class's data function, add the following:
if (role = = Qt::tooltiprole) {
QString name=index.data (Qt::D isplayrole). toString ();
Return Qtooltip.showtext (Qcursor.pos (), name);