ポイントを指定してコンテキストメニューを作成するスロットがあります。ただし、ポイントから位置を返すためにどの方法を使用しても、table->itemAt(pos) は常に 0 を返します。オフセットをリバース エンジニアリングできるように、テーブルの行/列の位置を出力する方法はありますか?
可能なすべての順列を試しましたが、常に「アイテムなし」が実行されます....
void test::newContextMenu(const QPoint& point)
{
QPoint pos = table_->viewport()->mapFromGlobal(point); //also tried
//table_->mapFromGlobal(point), table_>viewport()->mapToGlobal(point)
//table_->mapToGlobal(point), and QCursor::pos()
QAction* action tableMenu_->exec(pos);
if(action == XX)
{
QTableWidgetItem* item = table_->itemAt(pos);
if(!item)
{
///no item
}
....
}