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 Group Vs. Vector and Array

QAction Group Vs. Vector and Array

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 6.1k 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.
  • M Offline
    M Offline
    masoug
    wrote on last edited by
    #1

    Hi,
    I am just wondering what is so special about QActionGroup. Why can't I use arrays? (when I did, I ran into Segmentation Faults) and/or vectors? Is QActionGroup a special class that cannot be initiated in the form of an array?

    Also;

    @
    ...
    ActionGroup->addAction(myAction);
    delete myAction;
    @

    is "myAction" now part of "ActionGroup" or is it now deleted? Does QActionGroup store action objects?

    Thanks!

    -Masoug

    C++kie Monster

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      [quote author="masoug" date="1285381463"]Hi,
      I am just wondering what is so special about QActionGroup. ... Does QActionGroup store action objects?
      -Masoug[/quote]

      Have you checked the docs for QActionGroup in the Qt Assistant?

      @
      delete myAction;
      @

      If you want to remove myAction from the group, you should just use removeAction(myAction). Calling delete will "delete" myAction.

      1 Reply Last reply
      0
      • F Offline
        F Offline
        Franzk
        wrote on last edited by
        #3

        You can set a QActionGroup to be exclusive (only one action can be checked at a time). And more probably.

        "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

        http://www.catb.org/~esr/faqs/smart-questions.html

        1 Reply Last reply
        0
        • M Offline
          M Offline
          masoug
          wrote on last edited by
          #4

          [quote author="chetankjain" date="1285398264"]
          If you want to remove myAction from the group, you should just use removeAction(myAction). Calling delete will "delete" myAction.[/quote]

          So if I just call @delete myAction;@ will I still be able to find "myAction" in "ActionGroup"? Or does "ActionGroup" have a copy of "myAction"?

          Thanks!

          -Masoug

          C++kie Monster

          1 Reply Last reply
          0
          • F Offline
            F Offline
            Franzk
            wrote on last edited by
            #5

            [quote author="masoug" date="1285433909"]So if I just call @delete myAction;@ will I still be able to find "myAction" in "ActionGroup"? Or does "ActionGroup" have a copy of "myAction"?[/quote]

            Most certainly note. QActionGroups holds a pointer to myAction. When myAction is deleted, QActionGroup receives the destroyed() signal from myAction and removes it from it's internal list.

            Having said that, it's always better/safer to call deleteLater() on QObjects:

            @myAction->deleteLater()@

            "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • M Offline
              M Offline
              masoug
              wrote on last edited by
              #6

              Okay, Thanks! I got it now.

              -Masoug

              C++kie Monster

              1 Reply Last reply
              0
              • M Offline
                M Offline
                masoug
                wrote on last edited by
                #7

                Oh, and by the way, why does the compiler complain about a segmentation fault when I:

                @

                myAction[index] = QAction(tr("HI"), this);

                @

                That was kinda the basis of my question...

                Thanks!

                -Masoug

                C++kie Monster

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  DenisKormalev
                  wrote on last edited by
                  #8

                  masoug, what is myAction in this case and how have it been inititalized?

                  1 Reply Last reply
                  0
                  • F Offline
                    F Offline
                    Franzk
                    wrote on last edited by
                    #9

                    Do remember that QAction is a QObject and can therefore not be copied. If you want to pass the QAction around, use pointers to the thing.

                    @myAction[index] = new QAction(tr("HI"), this);@

                    Of course myAction has to be of the type QAction *[].

                    "Horse sense is the thing a horse has which keeps it from betting on people." -- W.C. Fields

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0

                    • Login

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