开发者

How to show tooltip when mouse pointer moves on an item drawn in QAbstractItemView subclass?

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?


If you haven't already done it, you should redefine the QAbstractItemView::indexAt function, which returns the QModelIndex at a given position in the view.

And in your model, you should set the tooltip text for your indexes as the role Qt::ToolTipRole or make your custom model QAbstractItemModel::data() function returns that text dynamically when asked for that role.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜