Hmm , try this:
void Widget::ProvideContextMenu( const QPoint& position )
{
if( index.isValid( ) ) // not neccessary , if you're about to perform item-independent actions
{
menuAction.setText("Demonstrational Text");
menu.addAction(&menuAction);
menu.exec( mapToGlobal( position ) );
}
}
void Widget::ProvideContextMenu( const QPoint& position )
{
QModelIndex index = indexAt(position);
if( index.isValid( ) ) // not neccessary , if you're about to perform item-independent actions
{
QMenu menu;
QAction menuAction(this);
menuAction.setText("Demonstrational Text");
menu.addAction(&menuAction);
menu.exec( mapToGlobal( position ) );
}
}
To copy to clipboard, switch view to plain text mode
Since initial point coordinates are given in the widget's local space (i mean , not in QWidget * QAbstractScrollArea::viewport () coordinates ) , we have to display it in the same space , using mapToGlobal function.
Bookmarks