簡體   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