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. MULTIPLE CHOICE QUIZ WITH QRADIOBUTTON
Forum Updated to NodeBB v4.3 + New Features

MULTIPLE CHOICE QUIZ WITH QRADIOBUTTON

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

    Hi, am creating a multi choice program I have many questions. I have used some radiobuttons, when I want to move to the next question I just use the setText() of the
    Qradiobutton. However, the option the user chose from the previous question remains checked.
    I have tried creating an array of radio button objects,however I didn't succeeded as I was using replaceWidget() of QLayout to change them any help please?

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

      Hi,

      You should consider having a "reset" method that will put the widget back in some initial state.

      You might want to also check QWizard for that kind of scenario.

      On a side note, please avoid all uppercased title, in written language it is considered shouting and rude.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply
      7
      • SGaistS SGaist

        Hi,

        You should consider having a "reset" method that will put the widget back in some initial state.

        You might want to also check QWizard for that kind of scenario.

        On a side note, please avoid all uppercased title, in written language it is considered shouting and rude.

        G Offline
        G Offline
        gblessed
        wrote on last edited by
        #3

        @SGaist
        Thanks, I have taken note of uppercase i was ignorant of that.
        I still have a challenge
        I created a QStackedWidget and then I added *widgets[50] to it, to each of the widgets I added 4 radiobuttons . at the last page of the widget when I want to check which radio button was checked it doesn't work .

        jsulmJ 1 Reply Last reply
        0
        • G gblessed

          @SGaist
          Thanks, I have taken note of uppercase i was ignorant of that.
          I still have a challenge
          I created a QStackedWidget and then I added *widgets[50] to it, to each of the widgets I added 4 radiobuttons . at the last page of the widget when I want to check which radio button was checked it doesn't work .

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @gblessed said in MULTIPLE CHOICE QUIZ WITH QRADIOBUTTON:

          when I want to check which radio button was checked it doesn't work .

          then please show how you're doing that

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply
          1
          • jsulmJ jsulm

            @gblessed said in MULTIPLE CHOICE QUIZ WITH QRADIOBUTTON:

            when I want to check which radio button was checked it doesn't work .

            then please show how you're doing that

            G Offline
            G Offline
            gblessed
            wrote on last edited by jsulm
            #5

            @jsulm
            In my header

            QStackedWidget *stacked = new QStackedWidget;
            QRadioButton * radio[200];
            QVBoxLayout *paged[50];
            QWidget *wiggy[50];
             
            //main window.cp
            int kj=0;
            for(int i=0; i<50; i++)
            { into 
            wiggy[i] = new QWidget();
            paged[i] = new QVBoxLayout;
            wiggy [i]->setLayout[paged[I];
            for(int j=0; j<4; j++){
            radio [kj] = new RadioButton(text);
            paged[i]->addWidget(radio [kj]);
            kj++;
            }
            
            }
            
            void on_pushbuttonclicked(){
            for(int i=0; i<200; i++){
            
            if(radio[i]->is checked())
            qDebug()<<"checked";
            }
            
            }
            
            jsulmJ 1 Reply Last reply
            0
            • G gblessed

              @jsulm
              In my header

              QStackedWidget *stacked = new QStackedWidget;
              QRadioButton * radio[200];
              QVBoxLayout *paged[50];
              QWidget *wiggy[50];
               
              //main window.cp
              int kj=0;
              for(int i=0; i<50; i++)
              { into 
              wiggy[i] = new QWidget();
              paged[i] = new QVBoxLayout;
              wiggy [i]->setLayout[paged[I];
              for(int j=0; j<4; j++){
              radio [kj] = new RadioButton(text);
              paged[i]->addWidget(radio [kj]);
              kj++;
              }
              
              }
              
              void on_pushbuttonclicked(){
              for(int i=0; i<200; i++){
              
              if(radio[i]->is checked())
              qDebug()<<"checked";
              }
              
              }
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @gblessed said in MULTIPLE CHOICE QUIZ WITH QRADIOBUTTON:

              radio [kj] = new RadioButton(text);

              Do you mean QRadioButton? Or is it your own class?
              Is any of the radio buttons checked when you press the button?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              G 1 Reply Last reply
              0
              • jsulmJ jsulm

                @gblessed said in MULTIPLE CHOICE QUIZ WITH QRADIOBUTTON:

                radio [kj] = new RadioButton(text);

                Do you mean QRadioButton? Or is it your own class?
                Is any of the radio buttons checked when you press the button?

                G Offline
                G Offline
                gblessed
                wrote on last edited by
                #7

                @jsulm sorry I meant QRadioButton
                None of the Radio buttons is checked however, if I connect the clicked(bool) signal of the QRadioButton to a slot, it works.

                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