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. QCheckBoxes
QtWS25 Last Chance

QCheckBoxes

Scheduled Pinned Locked Moved General and Desktop
8 Posts 6 Posters 2.6k 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
    arjita
    wrote on last edited by
    #1

    I am new to Qt ..can nyone tell me how can I add around 36 checkboxes in a wizard???

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Seba84
      wrote on last edited by
      #2

      Do you use Qt Creator or Qt Designer? You can do this using Qt user-interface.
      Otherwise you should create pointers and objects in your ui-class constructor (example from Qt Doc):

      @
      QCheckBox *checkbox = new QCheckBox("Case sensitive", this);
      @

      The best way to use Checkboxes is to use them inside QGroupBox.
      Hope it helps.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        leon.anavi
        wrote on last edited by
        #3

        Please read "QCheckBox":http://qt-project.org/doc/qt-5.0/qcheckbox.html documentation. QCheckBox inherits "QAbstractButton":http://qt-project.org/doc/qt-5.0/qabstractbutton.html and "QWidget":http://qt-project.org/doc/qt-5.0/qwidget.html so you can add it to a layout as a standard widget.

        http://anavi.org/

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          I'd suggest to re-think your GUI design. Do you really expect your users to find their way through 30+ checkboxes on a single page of a wizard? Is that a usable interface?

          If you must present that many checkboxes, and they are all on the same level, considder using a list with checkable items. Make sure you add a filter above the list to the user can trim down the list quickly to only the relevant items.

          1 Reply Last reply
          0
          • I Offline
            I Offline
            I-sty
            wrote on last edited by
            #5

            I think use dynamic checkboxes.

            This is my code, but this is C#.

            @private void GenerateDynamicControls(int amount)
            {
            //Clear existing
            pContainer.Controls.Clear();

                    for (int i = 0; i < amount; i++)
                    {
                        //Create the Textbox
                        TextBox dynamicTextbox = new TextBox();
                        dynamicTextbox.Name = "dynamicTextbox" + i.ToString();
                        dynamicTextbox.Width = 290;
                        dynamicTextbox.Height = 20;
                        dynamicTextbox.Left = 9;
                        dynamicTextbox.Top = 10 + (dynamicTextbox.Height * i) + (10 * i); //initial + height + padding
                        dynamicTextbox.Text = @"This is textbox number " + (i + 1).ToString();
            
                        //Create the Button
                        Button dynamicButton = new Button();
                        dynamicButton.Name = "dynamicButton" + i.ToString();
                        dynamicButton.Width = 75;
                        dynamicButton.Height = 23;
                        dynamicButton.Left = dynamicTextbox.Left + dynamicTextbox.Width + 5;
                        dynamicButton.Top = dynamicTextbox.Top; //Center the button vertically to textbox
                        dynamicButton.Text = "Show";
                        dynamicButton.Click += new EventHandler(Button_Click); //hook the Click event
            
                        //Add them to the container
                        pContainer.Controls.Add(dynamicTextbox);
                        pContainer.Controls.Add(dynamicButton);
                    }
                }@
            

            Sorry, for my bad English. My first language is Hungarian.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              absfrm
              wrote on last edited by
              #6

              Andre said right,36 checkBox in a single form are not good for interface!
              but! if you are newbie, u can use this method for generate dynamically controls :
              @
              for(int i=0;i<37;i++){
              QCheckBox *chkbox = new QCheckBox();
              chkbox->setText("test");
              chkbox->setParent(ui->groupBox);
              }
              @

              all of properties can be include in the "for" statement.
              have a good code ;)

              If You Want You Can!

              1 Reply Last reply
              0
              • A Offline
                A Offline
                arjita
                wrote on last edited by
                #7

                I am using 36 checkboxes for vertices in a graph .Checkboxes will consist of alphabets and digits and user will be required to check the box corresponding to vertices in his graph...

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  andre
                  wrote on last edited by
                  #8

                  Boy, it sure sounds I should be glad I don't have to use your application... Anyway, best of luck!

                  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