繁体   English   中英

是否可以从QModelIndex获取Qpoint

[英]Is it possible to get Qpoint from QModelIndex

是否可以从QModelIndex获取Qpoint。 我想获得一个Qpoint,以便我可以在某一行显示工具提示。

您可以使用QAbstractItemView::visualRect(const QModelIndex &index)返回由index处项目占用的视口上的矩形。 例如:

QRect rect = tableView->visualRect(index); // index is a QModelIndex
QPoint pos = tableView->mapToGlobal(rect.center());
QToolTip::showText(pos, "This is my tool tip", tableView, rect);

您应该实现模型,以便在请求Qt::ToolTipRole角色时返回工具提示内容。 这是向视图添加工具提示的正确模型视图方式。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM