Hello,
Goal: Display a context menu under a clicked column header in QTableView(with a horizontal QViewHeader being the 'parent' of the actions), with one of the actions being "Hide Column" which would hide the selected/clicked on column.
Issue:I know how to have a context menu appear with regular actions that trigger functions with no arguments but how do I pass an argument(a column number specifically) to this slot function?
Approach:My approach thus far has been to set the horziontal header's setContextMenuPolicy as Qt::CustomContextMenu, and then trigger a function like showContextMenu(const QPoint&).
showContextMenu(..)
QAction* hide = new QAction(tr("Hide Column"),this);
QMenu* popUp = new QMenu("Column Menu", this);
popUp->addAction(hide);
popUp->popup(mapToGlobal(p));
My goal is determine if I can get something like connect(hide, SIGNAL(triggered()), this, SLOT(hideColumn(int))); to work but my attempts have been unsuccessful. How do I do this or is there a better way to do this?
I hope I've made my issue clear.
Bookmarks