Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Link QAction availability to user selection
I've created some QActions into QMenus, I'd like to disable them if no selection is done in my main widget.
How can I do it ?
I'm aware of the QAction->setEnabled() method, but how can I link it to the user mouse selection ?
What kind of selection are you referring to ?
It's a user left-click selection of a
QTableView. The user data is stored into a
Then add a slot to the class that manages these actions and connect it to the selectionChanged signal of your selection model. In there check whether the selection is empty and update the action state accordingly.
I try that, thanks for you advice !
theo_ld last edited by theo_ld
@SGaist I tried this, but the selectionChanged signal doesn't exist in the QAction class.
connect(callAct, &QItemSelectionModel::selectionChanged, ipWidget, &IpWidget::onSelectionChanged);
Because it's a signal of QTableView.