I find the concept of QActions very appealing in terms of defining all action related things like text, icon, tool tip, checkable, keyboard shortcut and what not in one place, pointing it to the slot that is to be triggered, and then attaching the action to a button or a menu. But apparently this concept has not been thoroughly implemented and the suggestions made in this thread so far are redirections to the parts of the framework that work well together with QAction.

Obviously, QPushButtons ignore an attached QAction altogether. This fact is what started this thread in the first place. The suggestion to connect a QPushButton to a QAction and then the QAction to a slot makes the QAction an obsolete link in the chain according to my sense of simplicity. Perhaps it makes more sense in a mixed scenario, where QPushButtons, QToolButtons and QMenus are used in combination, but even then, the QPushButton would stick out of the pattern, because you would have to manually set up things for them that you already defined in the QAction. I wonder how a QPushButton supporting a QAction (for example by at least triggering it), would impair its general purpose applicability in any way.

Quote Originally Posted by anda_skoa View Post
Ranting about a proposed solution without even trying, trying something totally unrelated instead and ranting about that and all based on a question you didn't even want an answer for.
You are jumping to uninformed conclusions here. I have tried the QToolButton suggestion even before I made my second post in this thread. Yes, the QToolButton seems to be the only object that actually does the job of supporting QActions all the way. At least I have tested the tool tip and the checkable feature and whether it triggers the attached action or not. But adding a QToolButton to a QMenuBar clashes with QMenus and QActions added to the QMenuBar, because QToolButtons are widgets that would like to be inside a layout, while QMenus and QActions do their own thing automatically. So either you introduce an additional QToolBar with a layout to add your QToolButtons to, or you design some kind of layout hack that allows for QToolButtons to coexist with QMenus and QActions in a QMenuBar in some magic way. I didn't elaborate on it in this detail in my second post, since I focused on the wonderful possibility of adding QActions to a QMenuBar without ever defining a button, a layout, or even an additional tool bar. I wonder if I managed to convey the idea of this "totally unrelated" approach more clearly this time.

Now, as it turns out, QActions in QMenuBars do not show the tool tip, nor do they render a visual feedback of checkability.

Quote Originally Posted by ChrisW67 View Post
Checkable does work with an action in the QMenuBar. The QAction is marked checked and any QToolButton or QMenu items attached to that action are rendered "checked" when the item in the QMenuBar is clicked. The QMenuBar does not expect a menu to be on/off and consequently does not render a distinct "checked" look.
I understand that a QMenu in a QMenuBar does not need to be checkable, but a QAction in a QMenuBar is an entirely different thing. I don't see why it shouldn't be possible to visually support checkable and to show a tool tip in this case. Yes, QActions inside QMenus do support the checkable feature, but they also don't show the tool tip. And as tool tips and checkability are advertised parts of the QAction concept, I found these flaws disappointing.

Quote Originally Posted by ChrisW67 View Post
QPushButton and QToolButton are both QAbstractButtons [...] QMenuBar and QMenu is a hierarchical presentation of QActions [...] The range of options represents the range of common UI widgets on the various platforms Qt started on.
While QToolBar and QToolButton, QPushButton, and QMenu and QMenuBar may have a slightly different purpose in UI widgets, their functionality is essentially the same. You click on them and you trigger an action. My "ranting" is an attempt to make the point that all these objects could support QAction in a unified way by implementing all the features (tool tip, checkable etc.) that are promised by its interface and documentation.