Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How does QToolBar get it's buttons?
If you add Actions to a QToolBar somehow it generates QToolButtons and wires it up so that the Actions's signals are emitted when the button is clicked.
How does it do this, and what guidelines should I follow if I want to create my own "action containing" widget?
Franzk last edited by
Have a look at the "source":http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/widgets/qtoolbar.cpp, I'd say. Also look at http://doc.trolltech.com/latest/qwidget.html#addAction, for that is what QToolBar also uses.
The docs (and source) only show addAction appending the QAction to the Widget's internal list of actions.. nothing more.
What is QToolBar doing to generate it's buttons?
Also, since I'd like to build my own Action containing widget, I'd like to know if there is API or guidelines to model my widgets behavior after.
goetz last edited by
QToolBar creates the buttons from the list of QActions, using the icons and/or text of those.
I realize that QToolBar is making the buttons, but where / how is this happening?
The same question could be asked about QMenu.
The "source":http://qt.gitorious.org/qt/qt/blobs/4.7/src/gui/widgets/qtoolbar.cpp for QToolBar is not very clear on this point. (Or, at least, I did not spot it.)
Again, I am trying to build my own widget that can have actions added to it, and I'd like to see the right/"qt" way to make this happen.
andre last edited by
Line 979 is, I think, where you should start your trace of what happens.