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. [Solved] How to enable/disable Part of the QButtonGroup? Is it possible?
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to enable/disable Part of the QButtonGroup? Is it possible?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 2.9k 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.
  • H Offline
    H Offline
    Hareen Laks
    wrote on last edited by
    #1

    Hi,

    I have a application with three different radio buttons. I added them to a button group like below.

    @QButtonGroup *brackets_button_group;
    brackets_button_group = new QButtonGroup();

    //suppose I have enum BRACKET
    brackets_button_group->addButton(ui->a_radio_button,Bracket::A);
    brackets_button_group->addButton(ui->b_radio_button,Bracket::B);
    brackets_button_group->addButton(ui->c_radio_button,Bracket::C); @

    This button group is working as intended.

    But I need to enable/disable part of the button group according to some value as below.

    @if(my_value == 60)
    {
    //All buttons should be enabled
    }
    else if (my_value < 60)
    {
    //button c should be disabled and unchecked
    }
    else
    {
    //only c should be checked and enabled
    }@

    Is there any best practice for doing that, rather than enable/disable each button?

    Thanks for reading. :)

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

      Hi,

      Depending on how you manage your my_value variable you could use a QStateMachine to enable/disable your button accordingly. Otherwise no, there's no "partial" button group handling.

      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
      • H Offline
        H Offline
        Hareen Laks
        wrote on last edited by
        #3

        Thank you very much SGaist. It was done. :)

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

          Nice !

          Then please update the thread title prepending [solved] so other forum users may know a solution has been found :)

          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

          • Login

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