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. Checkable action does not set button checkd
Forum Updated to NodeBB v4.3 + New Features

Checkable action does not set button checkd

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.5k Views 1 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.
  • B Offline
    B Offline
    butterface
    wrote on last edited by
    #1

    Hi,

    shouldn't a checkable QAction also set its state to a control which it is added to? E. g. a button where the action is added to through addAction?

    bf

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      It is just a action added QWidget. Widgets can have many actions. Not just one action. What is the basis for changing the state of widget to which it is added ? It is not one-to-one mapping. QAction is mainly used with context menus or menu items. So there are always multiple actions associated with main widget. May be you have specific use case just with Button and QAction. In generic usage it does not fit in.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • B Offline
        B Offline
        butterface
        wrote on last edited by
        #3

        I am aware of that but what sense does it make then that an action can be checkable? If it is that generic and so on this property does not really make sense to me because I have to take care of that state anyway. Especially this property would make it less general for me (e. g. it does not support tristate).

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

          Hi,

          In order to sync a checkable button and a checkable action, typically you would connect the action toggled signal to the setChecked slot of the button. And also vice-versa

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

            @SGaist: Thanks for that advice. Synchronizing them is actually not the problem. It is more questioning the design or asking for the background of that.

            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