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] Display QgroupBox on main window.
Forum Updated to NodeBB v4.3 + New Features

[Solved] Display QgroupBox on main window.

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

    Hi,

    I would like to create and display a QgroupBox on my main window.
    So far I do that:
    @ QGroupBox *groupB=new QGroupBox();
    QVBoxLayout *vbox = new QVBoxLayout();
    int n=3;
    QPushButton *button[n];
    for(int i=1;i<=n;i++)
    {
    button[i]=new QPushButton();
    button[i]->setText(i);
    vbox->addWidget(button[i]);
    }
    groupB->setLayout(vbox);
    groupB->show();@

    The group of boxes is created and display but on a "pop up" window.
    How should I proceed to change this?

    Thanks

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

      Hi,

      You can call

      @setCentralWidget(groupB);@

      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
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        And remove
        @groupB->show();@
        If main function calls show() for main window.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          laetis
          wrote on last edited by
          #4

          Ahhhhh I remember reading that somewhere. It works perfectly.
          Thanks

          1 Reply Last reply
          0
          • L Offline
            L Offline
            laetis
            wrote on last edited by
            #5

            And if I want to hide it again?

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

              @groupB->hide();@

              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
              • L Offline
                L Offline
                laetis
                wrote on last edited by
                #7

                could not have been more straightforward!

                Thanks

                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