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. QMenu use menuaction
Forum Updated to NodeBB v4.3 + New Features

QMenu use menuaction

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 787 Views 2 Watching
  • 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.
  • Y Offline
    Y Offline
    yjx--30k
    wrote on last edited by
    #1

    I want to that QMenu don't add any action , use itself menuaction,I am trying to implement the triggering operation of the menu action, but I keep receiving warnings that the menu action signal is not being received.Do you have any suggestions? Because I want to implement a special effect.9c78f5ea-2573-4e9f-88e0-8b56d71d7223-0A129D90-5E63-4441-9A24-4FBDA89BA1E2.png 2b123ecb-3c10-4d87-88b2-a230312d2ee6-9CC29979-974F-416a-852B-0D636FC2183E.png

    jsulmJ Pl45m4P C 3 Replies Last reply
    0
    • Y yjx--30k

      I want to that QMenu don't add any action , use itself menuaction,I am trying to implement the triggering operation of the menu action, but I keep receiving warnings that the menu action signal is not being received.Do you have any suggestions? Because I want to implement a special effect.9c78f5ea-2573-4e9f-88e0-8b56d71d7223-0A129D90-5E63-4441-9A24-4FBDA89BA1E2.png 2b123ecb-3c10-4d87-88b2-a230312d2ee6-9CC29979-974F-416a-852B-0D636FC2183E.png

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @yjx-30k It is not clear what exactly you are doing (code) and what exact warning you get. Please provide more precise information.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      Y 1 Reply Last reply
      1
      • Y yjx--30k

        I want to that QMenu don't add any action , use itself menuaction,I am trying to implement the triggering operation of the menu action, but I keep receiving warnings that the menu action signal is not being received.Do you have any suggestions? Because I want to implement a special effect.9c78f5ea-2573-4e9f-88e0-8b56d71d7223-0A129D90-5E63-4441-9A24-4FBDA89BA1E2.png 2b123ecb-3c10-4d87-88b2-a230312d2ee6-9CC29979-974F-416a-852B-0D636FC2183E.png

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #3

        @yjx-30k said in QMenu use menuaction:

        I want to that QMenu don't add any action

        but I keep receiving warnings that the menu action signal is not being received

        If I'm not mistaken, the function you are referring to is just the getter for the associated QAction. Since you dont set any action, you cant receive any signals.
        Just a guess... for more details please post the code what exactly you are doing.


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        Y 1 Reply Last reply
        1
        • Y yjx--30k

          I want to that QMenu don't add any action , use itself menuaction,I am trying to implement the triggering operation of the menu action, but I keep receiving warnings that the menu action signal is not being received.Do you have any suggestions? Because I want to implement a special effect.9c78f5ea-2573-4e9f-88e0-8b56d71d7223-0A129D90-5E63-4441-9A24-4FBDA89BA1E2.png 2b123ecb-3c10-4d87-88b2-a230312d2ee6-9CC29979-974F-416a-852B-0D636FC2183E.png

          C Offline
          C Offline
          CPPUIX
          wrote on last edited by CPPUIX
          #4

          Hi,

          If you don't want to add any actions to your QMenu, but still want to receive a signal when it is clicked, you could take a look at this:

          • How to perform action on clicking a QMenu object only?

          Basically, you'd have to use QMenu::aboutToHide and QMenu::aboutToShow signals instead of QMenu::triggered

          connect(ui->yourMenu, &QMenu::aboutToHide, [this](){ //do something });
          connect(ui->yourMenu, &QMenu::aboutToShow, [this](){ //do something });
          

          A comment there says:

          with that there is a bug here, when moving mouse on this menu, without clicking, the slot trigering automatically.

          I couldn't reproduce that behavior.

          1 Reply Last reply
          0
          • jsulmJ jsulm

            @yjx-30k It is not clear what exactly you are doing (code) and what exact warning you get. Please provide more precise information.

            Y Offline
            Y Offline
            yjx--30k
            wrote on last edited by
            #5

            @jsulm I want to achieve a special effect using a menu. Previously, I used an action to do it, but I found that clicking between the action and other menus caused a position shifting phenomenon. I want to solve this problem, but I cannot add any additional actions to the menu because it will form a context menu. I just want to use this special menu with color as a button. Overriding the resize event of the menuBar is too complicated.8300b22f-d4b0-4d1b-b477-23631c03d058-1695865070942_5E02F64E-0A94-4288-A0DE-698AE4986239.png

            1 Reply Last reply
            0
            • Pl45m4P Pl45m4

              @yjx-30k said in QMenu use menuaction:

              I want to that QMenu don't add any action

              but I keep receiving warnings that the menu action signal is not being received

              If I'm not mistaken, the function you are referring to is just the getter for the associated QAction. Since you dont set any action, you cant receive any signals.
              Just a guess... for more details please post the code what exactly you are doing.

              Y Offline
              Y Offline
              yjx--30k
              wrote on last edited by
              #6

              @Pl45m4 I want to achieve a special effect using a menu. Previously, I used an action to do it, but I found that clicking between the action and other menus caused a position shifting phenomenon. I want to solve this problem, but I cannot add any additional actions to the menu because it will form a context menu. I just want to use this special menu with color as a button. Overriding the resize event of the menuBar is too complicated.
              5bb14d4c-c8e4-4c6d-969b-acb06f9a9410-1695865070942_5E02F64E-0A94-4288-A0DE-698AE4986239.png

              Pl45m4P 1 Reply Last reply
              0
              • Y yjx--30k

                @Pl45m4 I want to achieve a special effect using a menu. Previously, I used an action to do it, but I found that clicking between the action and other menus caused a position shifting phenomenon. I want to solve this problem, but I cannot add any additional actions to the menu because it will form a context menu. I just want to use this special menu with color as a button. Overriding the resize event of the menuBar is too complicated.
                5bb14d4c-c8e4-4c6d-969b-acb06f9a9410-1695865070942_5E02F64E-0A94-4288-A0DE-698AE4986239.png

                Pl45m4P Offline
                Pl45m4P Offline
                Pl45m4
                wrote on last edited by
                #7

                @yjx-30k

                Are you talking about the menu in the standard MenuBar of QMainWindow?
                So you want to color it or change the style in other ways?
                What about stylesheet?
                Like here

                • https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qmenu

                If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                ~E. W. Dijkstra

                Y 1 Reply Last reply
                0
                • Pl45m4P Pl45m4

                  @yjx-30k

                  Are you talking about the menu in the standard MenuBar of QMainWindow?
                  So you want to color it or change the style in other ways?
                  What about stylesheet?
                  Like here

                  • https://doc.qt.io/qt-6/stylesheet-examples.html#customizing-qmenu
                  Y Offline
                  Y Offline
                  yjx--30k
                  wrote on last edited by
                  #8

                  @Pl45m4 Thank you, but I am facing a more serious problem. I want to achieve the effect of clicking and checked attribute on the menu to switch pages. I did this through aboutToShow(), but I found that triggering would be automatically triggered when the mouse moved over the menu. Do you have a better solution? I also searched on Stack Overflow, but unfortunately there was no good solution. Link: https://stackoverflow.com/questions/22197496/how-to-perform-action-on-clicking-a-qmenu-object-only/22197619#22197619.

                  1 Reply Last reply
                  0
                  • C Offline
                    C Offline
                    CPPUIX
                    wrote on last edited by
                    #9

                    Are you trying to make a QTabWidget?

                    It sounds (and looks) like you're trying to use the menubar as a tab bar.

                    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