when i use the code below, Qt puts labels on the right side.
How can i put labels centered in the line?
{
ui.setupUi(this);
mainlayout->addWidget(label1);
mainlayout->addWidget(label2);
mainlayout->addWidget(label3);
mainlayout->addWidget(label4);
ui.centralWidget->setLayout(mainlayout);
}
myproject::myproject(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
{
ui.setupUi(this);
QVBoxLayout *mainlayout = new QVBoxLayout;
QLabel *label1= new QLabel("aaa");
QLabel *label2= new QLabel("bbb");
QLabel *label3= new QLabel("cccc");
QLabel *label4= new QLabel("ddd");
mainlayout->addWidget(label1);
mainlayout->addWidget(label2);
mainlayout->addWidget(label3);
mainlayout->addWidget(label4);
ui.centralWidget->setLayout(mainlayout);
}
To copy to clipboard, switch view to plain text mode
Bookmarks