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. Use the push button as a check button and use the grouping function
Forum Updated to NodeBB v4.3 + New Features

Use the push button as a check button and use the grouping function

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 335 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1

    I know that I need to put setchakable(true) to use the pushbutton as a radio button.

    Is there a way to automatically check each other's click status when creating multiple chakable buttons?

    For example in C# you can group radio buttons so that only one is selected. Does qt provide the same functionality like this one?

    JonBJ 1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Write it by yourself - a simple for loop isn't that hard.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      I 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Write it by yourself - a simple for loop isn't that hard.

        I Offline
        I Offline
        IknowQT
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        There seems to be such a thing as a button group, how about applying it?

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @IknowQT said in Use the push button as a check button and use the grouping function:

          how about applying it?

          What apply? Instantiate it, add buttons via addButton() and look if it works the way you want.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • I IknowQT

            I know that I need to put setchakable(true) to use the pushbutton as a radio button.

            Is there a way to automatically check each other's click status when creating multiple chakable buttons?

            For example in C# you can group radio buttons so that only one is selected. Does qt provide the same functionality like this one?

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by JonB
            #5

            @IknowQT said in Use the push button as a check button and use the grouping function:

            For example in C# you can group radio buttons so that only one is selected. Does qt provide the same functionality like this one?

            Yes QButtonGroup has that functionality. Note it says:

            QButtonGroup provides an abstract container into which button widgets can be placed. It does not provide a visual representation of this container (see QGroupBox for a container widget), but instead manages the states of each of the buttons in the group.

            So you still add your buttons onto whatever widgets like QGroupBox for visual layout, you also add the buttons onto the (non-visual) QButtonGroup for the behaviour (like exclusivity) you want.

            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