Qt:Attempting to add QLayout “” to MainWindow “”, which already has a layout
意思是,試圖添加一個佈局到mainwindow上,但實際上該佈局已經存在了。
我原來的代碼:
QVBoxLayout *layoutt = new QVBoxLayout(this);
現在改爲:
QVBoxLayout *layoutt = new QVBoxLayout(ui->show_widget);
**總結:**佈局layout的父窗體 要具體指定,如果指定爲this就是當前窗體,但我想在固定的窗體上添加,就不能是this 了