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. GroupBox problem

GroupBox problem

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.3k 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.
  • A Offline
    A Offline
    aklenczar
    wrote on last edited by
    #1

    Hello. I've got a question about groupBox. I add 2 radioButtons, groupBox and label on form. I want to set text of the label when radioButton is checked. But I don't know how to use ui.groupBox to access the radiobutton's state.
    I will be glad for any help.
    Regards

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      The short answer is - you don't. Groupbox knows nothing about the radiobutton's state. Why would it?

      Assuming you have a radiobutton added in the designer you would connect a custom slot to it's toggled() signal and set your label content there.

      Example:

      @
      //somewhere in the MainWindow constructor
      connect(ui.radioButton, SIGNAL(toggled(bool)), this, SLOT(someSlot(bool)));

      //and in your custom slot:
      void MainWindow::someSlot(bool state)
      {
      if(state)
      ui.myLabel->setText("state 1");
      else
      ui.myLabel->setText("state 2");
      }
      @
      groupbox has basically nothing to do with it.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        aklenczar
        wrote on last edited by
        #3

        Thank you for your answer. I have to think about it and rewrite it in the way you wrote here.

        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