方法1,删除centralWidget后,添加手动部分内容。

    left = new QPushButton("killin kind");
right = new QPushButton("Emma");
    if(this->centralWidget())    {
       delete this->centralWidget();
    }   else    {    }
    QHBoxLayout *hLayout= new QHBoxLayout;
QWidget *cWidget = new QWidget(this);
this->setCentralWidget(cWidget);
    hLayout->addWidget(left);
hLayout->addWidget(right);
hLayout->addWidget(labelPos);
cWidget->setLayout(hLayout);
2.就是直接使用这个窗口内部的Layout对象
this->layout()->addWidget(left);


相关文章:

  • 2022-01-16
  • 2021-08-23
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-12
  • 2021-09-19
  • 2021-12-14
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
相关资源
相似解决方案