I’ve implemented QAbstractItemView to show a tabular model (having two columns, one for x axis another for corresponding y axis) in line chart style. To do that I reimplemented QAbstractItemView::paintEvent(). The chart is now shown and each data is drawn by a little circle. When mouse pointer hovers over the circles (representing (x, y) on the chart for some data) I want to show tooltip that will display original data in (x, y) format. How can I do this?
I’ve implemented QAbstractItemView to show a tabular model (having two columns, one for x
Share
If you haven’t already done it, you should redefine the
QAbstractItemView::indexAtfunction, which returns theQModelIndexat a given position in the view.And in your model, you should set the tooltip text for your indexes as the role
Qt::ToolTipRoleor make your custom modelQAbstractItemModel::data()function returns that text dynamically when asked for that role.