QAction system in QT - LOGIC - is this how it works?
-
Hey
So a while back I wrote a system using qActions, its quite complex as it uses qToolBar/Qmenu/QToolButton/ QACtionWidget and more. Its fairly - "WTF".
So I decided to redo it in a more "proper" way. But before I can do that, I think its time to properly learn how that system works. So I made a graph. Can any1 have a look and let me know if this is how the system internally works in QT for QActions?
I'm a tad lost... Well not really, but unsure. Anyway :
TIA
Regards
Dariusz -
Hi,
The action doesn't activate all these buttons, it's the other way around: any of these buttons activate the action.
-
What do you mean by nested ?
-
Well each toolbar holds a list of qtoolButtons and each toolButton holds a pointer to action that he notifies when button gets pressed ?
One of the things that keeps bugging me is that the source code seems to not support that. So I'm bit lost. In source adding action just puts it in qlist of actions. There is no toolbutton creation/configuration. So I'm a bit lost. Maybe action is a toolbutton in itself somehow and don't need that? but then if I add the same action to 2 qtoolbars, they can be shared. Oh wait, maybe I have to add them to toolbuttons for sharing to work and action don't share on their own? hmmm
-
It's the QToolbarLayout private class that does the "magic" behind creating the buttons and putting them a the right place.
The action handling is at the QWidget level.
-
Woa thanks lots !
I saw sometimes the "private" classes but they never really pop up when I read the source when I follow up the command hierarchy. I take they are the inner workings on qt? How come they are not virtual, I mean, how are they being called ? I guess thats my lack of C++ understanding on QT here tbh.
In any case thanks! Reading up private class has cleaned up few things - or quite a lot actually.
So I went over QAction to try & understand how the sub system work a little more with signals. It looks like QAction holds a QList<QWidget *> associatedWidgets() const; which then gets notified when ever that actionGets pressed. I take if that action is a checkbox, and persist in other toolbars as a toolButton. Then they get notified and update accordingly.
So I wonder, - if I create QWidgetAction, and assign to it a QWidget. - then add layout to it with different widgets/checkboxes/etc. Would the children emit a similar signal and allow me to have a set of 2x widget layouts/sub widgets being mirrored/cloned? Or this only works directly on the widget - like only qlineedit/checkbox/combo box etc etc? - gonna try it now actually o.o.
Thanks for the help & your time.
Regards
Dariusz -
@Dariusz said in QAction system in QT - LOGIC - is this how it works?:
So I wonder, - if I create QWidgetAction, and assign to it a QWidget. - then add layout to it with different widgets/checkboxes/etc. Would the children emit a similar signal and allow me to have a set of 2x widget layouts/sub widgets being mirrored/cloned? Or this only works directly on the widget - like only qlineedit/checkbox/combo box etc etc? - gonna try it now actually o.o.
Sadly nope.
The sub widgets don't get sub copied. Or I did something wrong.TIA.