天天看點

setLayout: Attempting to set QLayout "" on MainWindow "MainWindow", which already has a layout

MainWindow::MainWindow(QWidget *parent)

: QMainWindow(parent)      
{      
QString xStr;      
xLabel = new QLabel(tr("x():"));      
xValueLabel = new QLabel;      
xValueLabel->setText(xStr.setNum(x()));      
QGridLayout *grdLayout = new QGridLayout;      
grdLayout->addWidget(xLabel,0,0);      
grdLayout->addWidget(xValueLabel,0,1);      
QWidget *widget = new QWidget( this);      
widget->setLayout( grdLayout) ;      
this->setCentralWidget(widget);      
}      

繼續閱讀