Prevent a QMenu from closing when one of its QAction is triggered

前端 未结 6 1871
北荒
北荒 2020-12-15 06:30

I\'m using a QMenu as context menu. This menu is filled with QActions. One of these QActions is checkable, and I\'d like to be able to check/uncheck it without closing the c

6条回答
  •  执念已碎
    2020-12-15 07:01

    Here are couple ideas I've had... Not sure at all they will work tho ;)

    1) Try to catch the Event by using the QMenu's method aboutToHide(); Maybe you can "Cancel" the hide process ?

    2) Maybe you could consider using an EventFilter ?

    Try to have a look at : http://qt.nokia.com/doc/4.6/qobject.html#installEventFilter

    3) Otherwise you could reimplement QMenu to add your own behavior, but it seems a lot of work to me...

    Hope this helps a bit !

提交回复
热议问题