Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAction system in QT - LOGIC - is this how it works?
QtWS25 Last Chance

QAction system in QT - LOGIC - is this how it works?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qactionqtoolbarqtoolbuttonqwidgetaction
9 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dariusz
    wrote on 9 Oct 2018, 19:02 last edited by
    #1

    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 :

    https://imgur.com/a/tGycmed

    TIA
    Regards
    Dariusz

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 9 Oct 2018, 19:28 last edited by
      #2

      Hi,

      The action doesn't activate all these buttons, it's the other way around: any of these buttons activate the action.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • D Offline
        D Offline
        Dariusz
        wrote on 9 Oct 2018, 20:10 last edited by
        #3

        So a button notifies action to emit action signal which was specified by user?

        What about the order of creation, is it all the way I illustrated it? Each action is nested within QToolButton?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 9 Oct 2018, 20:24 last edited by
          #4

          What do you mean by nested ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • D Offline
            D Offline
            Dariusz
            wrote on 9 Oct 2018, 20:48 last edited by
            #5

            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

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 10 Oct 2018, 06:41 last edited by
              #6

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              1
              • D Offline
                D Offline
                Dariusz
                wrote on 10 Oct 2018, 18:28 last edited by
                #7

                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

                D 1 Reply Last reply 10 Oct 2018, 19:13
                0
                • D Dariusz
                  10 Oct 2018, 18:28

                  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

                  D Offline
                  D Offline
                  Dariusz
                  wrote on 10 Oct 2018, 19:13 last edited by
                  #8

                  @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.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 10 Oct 2018, 19:30 last edited by
                    #9

                    QObject are not copiable, see here for the why.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    3/9

                    9 Oct 2018, 20:10

                    topic:navigator.unread, 6
                    • Login

                    • Login or register to search.
                    3 out of 9
                    • First post
                      3/9
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved