Solved How to do this layout in code (runtime)
-
Can anyone help me with how to to this layout in code?
-
Why not use Qt designer for it? And even if you won't use designer you can use the generated code from there and adjust it afterwards.
-
@R_Irudezu
because it's close to christmas:int main(int argc, char *argv[]) { QApplication a(argc, argv); QFrame *frame = new QFrame(); frame->setStyleSheet("QLabel{background-color:white; border: 1px solid black;}"); QGridLayout *gLayout = new QGridLayout(frame); gLayout->addWidget(new QLabel(frame),0,0,1,3); gLayout->addWidget(new QLabel(frame),1,0,3,1); gLayout->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding),1,1,1,1); gLayout->addWidget(new QLabel(frame),2,1,1,1); gLayout->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding),3,1,1,1); gLayout->addWidget(new QLabel(frame),1,2,3,1); frame->resize(400,200); frame->show(); return a.exec(); }
-
@Christian-Ehrlicher i was creating widgets at runtime but it is a great idea that creating widgets in designer and check the codes but i will try first @J-Hilk ' s instance. (These row, column and spans numbers confuse me so much :/ )
Addition: @J-Hilk many thanks, it's done. I need to do more practice about layouts :)