when i use the code below, Qt puts labels on the right side.
How can i put labels centered in the line?

Qt Code:
  1. myproject::myproject(QWidget *parent, Qt::WFlags flags): QMainWindow(parent, flags)
  2. {
  3. ui.setupUi(this);
  4.  
  5. QVBoxLayout *mainlayout = new QVBoxLayout;
  6. QLabel *label1= new QLabel("aaa");
  7. QLabel *label2= new QLabel("bbb");
  8. QLabel *label3= new QLabel("cccc");
  9. QLabel *label4= new QLabel("ddd");
  10. mainlayout->addWidget(label1);
  11. mainlayout->addWidget(label2);
  12. mainlayout->addWidget(label3);
  13. mainlayout->addWidget(label4);
  14. ui.centralWidget->setLayout(mainlayout);
  15.  
  16.  
  17. }
To copy to clipboard, switch view to plain text mode