How can I get trigger signal for disabled QAction element?

孤人 提交于 2019-12-11 02:08:58

问题


I have disabled QAction menu element:

QAction *item = new QAction(itemTitle);
item->setEnabled(false);

I use SLOT connection to call function after element was pressed, but it's works only for enabled elements:

QObject::connect(item, SIGNAL(triggered()), this, SLOT(func()));

My question is how can I trigger some function for disabled QAction element?

Qt 5.9.2, MSVC2017 64bit compiler


回答1:


setEnabled() property holds whether the widget is enabled.

In general an enabled widget handles keyboard and mouse events; a disabled widget does not. An exception is made with QAbstractButton.

When a widget is disable, all mouse and keyboard events are also disable.

More info : http://doc.qt.io/qt-4.8/qwidget.html#enabled-prop



来源:https://stackoverflow.com/questions/46767095/how-can-i-get-trigger-signal-for-disabled-qaction-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!