Hi,
I am success to create contextmenu in QTableView. I think this is same with QTableWidget. You can use this
QHeaderView * QTableView::horizontalHeader () const
To copy to clipboard, switch view to plain text mode
This is a sample code :
//connect horizontal header QTableView with contextmenu
horizontalHeader = tblv->horizontalHeader();
horizontalHeader->setContextMenuPolicy(Qt::CustomContextMenu); //set contextmenu
connect(horizontalHeader, SIGNAL(customContextMenuRequested( const QPoint& )),
this, SLOT(tablev_customContextMenu( const QPoint& )));
QTableView *tblv;
QHeaderView *horizontalHeader;
//connect horizontal header QTableView with contextmenu
horizontalHeader = tblv->horizontalHeader();
horizontalHeader->setContextMenuPolicy(Qt::CustomContextMenu); //set contextmenu
connect(horizontalHeader, SIGNAL(customContextMenuRequested( const QPoint& )),
this, SLOT(tablev_customContextMenu( const QPoint& )));
To copy to clipboard, switch view to plain text mode
You can modified this with your problem. This site have a sample how to create contextmenu in QTableView. I think you can use that.
http://toto-share.com/2011/07/contex...in-qtableview/
Best regards,
myta212
Bookmarks