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

http://blog.csdn.net/zhuyingqingfen/article/details/6562246

如题,出现这个的原因是,如果你的窗口继承的是QMainwindow,需要设置

setCentralWidget();

如下:
  1. QWidget* widget = new QWidget(mainWindow);
  2. widget->setLayout(gridLayout);
  3. mainWindow->setCentralWidget(widget);
设置好一个widget即可
posted @ 2013-12-05 16:12  LittleAnt  阅读(1577)  评论(0编辑  收藏  举报