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. how to create nested QGroupBox with recursion ?
Qt 6.11 is out! See what's new in the release blog

how to create nested QGroupBox with recursion ?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.1k 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.
  • AhtiA Offline
    AhtiA Offline
    Ahti
    wrote on last edited by
    #1

    Here is my code so far :

    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
        QFrame *test = new QFrame(this);
        layout = new QGridLayout;
        test->setGeometry(10,10,150,300);
        layout->addWidget(createBrightnessSettings(tr("Brightness Settings"),5,30,300,275),0,0,3,3,Qt::AlignLeft);
        test->setLayout(layout);
    }
    
    QGroupBox *MainWindow::createBrightnessSettings(const QString& name,int x,int y,int w,
                                                 int h){
    
        QGroupBox *brightnessSettings = new QGroupBox(name);
    
        if (name == "Brightness Settings"){
            brightnessSettings->setFlat(true);
            layout->addWidget(createBrightnessSettings(tr("Day Mode"),30,55,250,95),0,1,0,3,Qt::AlignLeft);
        }
        //createBrightnessSettings("Night Mode",30,170,250,95);
    
        if (name != "Brightness Settings"){
    
            //startfrom = constructLabel(settingsBackground,startfrom,"color:rgb(200,200,200);font:9pt bold Arial;",
              //                     50,68,90,25,"Start From");
        }
        brightnessSettings->setGeometry(x,y,w,h);
        return brightnessSettings;
    }
    

    This is what i want :

    https://postimg.org/image/i30xl23g5/

    thanks

    what is a signature ?? Lol

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

      Hi,

      Set a QVBoxLayout in your main QGroupBox and then add the other two to that layout.

      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
      2

      • Login

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