I can only help you with the first problem:
You can advice the QTreeView to emit a signal when a context menu event occurs and handle it in another QObject derived class, e.g. the parent widget of the tree view.
To accomplish this you need to change the context menu policy of the view:
// let tv be a pointer to your treeview
tv->setContextMenuPolicy( Qt::CustomContextMenu );
// let tv be a pointer to your treeview
tv->setContextMenuPolicy( Qt::CustomContextMenu );
To copy to clipboard, switch view to plain text mode
This causes the tree view to emit the "customContextMenuRequested( const QPoint& )" signal.
The slot for the signal to connect to may look like:
void CMyClass::ProvideContexMenu( const QPoint& pnt ){
if( idx.isValid( ) )
MyContextMenu->popup( tv->mapToGlobal( pnt ) );
}
void CMyClass::ProvideContexMenu( const QPoint& pnt ){
QModelIndex idx = tv->indexAt( pnt );
if( idx.isValid( ) )
MyContextMenu->popup( tv->mapToGlobal( pnt ) );
}
To copy to clipboard, switch view to plain text mode
Usually you need to remember the index, to apply the user selected action to it.
Bookmarks