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 in toolbar and menu - refresh problem

QAction in toolbar and menu - refresh problem

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 983 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.
  • J Offline
    J Offline
    jojo26
    wrote on last edited by
    #1

    Hi

    maybe someone can help as I am a newbie in Qt...

    I have a set of checkable QActions grouped in a QActionGroup. This ActionGroup is added to a menu and to a toolbar. From a functional point of view everthing works fine.

    The problem is:

    When checking the toolbar button and then opening the menu, the belonging menu item is also checked -> ok
    When checking a menu item, the belonging toolbar button won't be checked -> bad

    It tried no for a quite while, but I couldn't make it. Also I'm not able to set the (visual) state of these toolbar buttons with setChecked() in the program...

    Any help would be appreciated!

    Thanks
    Jochen

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #2

      Have you setExclusive(true) for your QActionGroup? If so, and your QMenu item that contains the other checkable items is also part of the group, then you will get your observed behavior. Remove the top-level menu item from the group. You can set up logic to check that item if one of the sub-items is checked.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        jojo26
        wrote on last edited by
        #3

        Thank You for your reply!

        .. yes, the actions are exclusiv (default beahviour) - and no, the action group only holds sub items of the top level menu ... mmh

        The toolbar and menu is hidden (and shown) as the user switches the view in the main window. Could the problem relate to this?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi and welcome to devnet,

          Can you provide a minimal buildable sample code that shows that behaviour ?

          Also:

          • What version of Qt are you using ?
          • What OS are you running ?

          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
          • J Offline
            J Offline
            jojo26
            wrote on last edited by
            #5

            ... thank you for your warm welcome!

            It's quite a big engineering software - and I my knowledge is not enough to extract just this part to show the problem... I'm using Qt 5.12.1 on Windows 10.

            Looking at the effect it seems, that QAction object lost it's "link" to the toolbar button widget - whereas the button is still linked to the Action object...

            1 Reply Last reply
            0
            • J Offline
              J Offline
              jojo26
              wrote on last edited by
              #6

              ... problem solved.

              There was a bug in the program. The QAction objects were re-created twice but then not re-assigned to the toolbar object, but re-assigned to the menu...

              Thank You for your support!

              1 Reply Last reply
              1

              • Login

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