QGroupBox issues
-
Okay, I'm trying to group up some labels and line edits in a stacked widget, but I'm having trouble understanding how to do it.
Currently, I have this code:int z=0; for (int i=0; i<3; i++) { QVBoxLayout *vertical=new QVBoxLayout; QWidget *page = new QWidget; for (int j = 0; j < 5; j++) { //QGroupBox *grp=new QGroupBox(); QLabel *lbl=new QLabel("Something("+QString::number(z)+")"); QLineEdit *txt=new QLineEdit(); vertical->addWidget(lbl); vertical->addWidget(txt); z++; } page->setLayout(vertical); ui->stck->insertWidget(i, page); } ui->stck->setCurrentIndex(0);This code looks like:

What I would like to do is:

The purpose of this is I'm making a quiz maker for my school project and this is how I'm thinking of grouping questions with answers, if anyone's got a better idea, let me know. -
Okay, I'm trying to group up some labels and line edits in a stacked widget, but I'm having trouble understanding how to do it.
Currently, I have this code:int z=0; for (int i=0; i<3; i++) { QVBoxLayout *vertical=new QVBoxLayout; QWidget *page = new QWidget; for (int j = 0; j < 5; j++) { //QGroupBox *grp=new QGroupBox(); QLabel *lbl=new QLabel("Something("+QString::number(z)+")"); QLineEdit *txt=new QLineEdit(); vertical->addWidget(lbl); vertical->addWidget(txt); z++; } page->setLayout(vertical); ui->stck->insertWidget(i, page); } ui->stck->setCurrentIndex(0);This code looks like:

What I would like to do is:

The purpose of this is I'm making a quiz maker for my school project and this is how I'm thinking of grouping questions with answers, if anyone's got a better idea, let me know.for (int j = 0; j < 5; j++) { QGroupBox *grp=new QGroupBox(); QVBoxLayout *grpLayout = new QVBoxLayout(); QLabel *lbl=new QLabel("Something("+QString::number(z)+")"); QLineEdit *txt=new QLineEdit(); grpLayout->addWidget(lbl); grpLayout->addWidget(txt); grp->setLayout(grpLayout); vertical->addWidget(grp); z++; }Cf. https://doc.qt.io/qt-5/qgroupbox.html#details sample code box.