18:28:21: Debugging starts
QLayout: Attempting to add QLayout “” to MainWindow “MainWindow”, which already has a layout
问题原因:
If MainWindow is a QMainWindow and you build centralWidget in MainWindow just call setCentralWidget(centralWidget);
You can’t set a layout on a QMainWindow because it already has one that makes all the work for dock widgets etc.
QMainWindow 本身已经有一个layout了,不能再设置layout了。
之所以报错,是因为在QMainWindow中某个成员函数中,使用了:
QGridLayout *t_gridLayout_map = new QGridLayout(this);
改进措施:
QGridLayout *t_gridLayout_map = new QGridLayout();
去掉this之后,OK!!!
————————————————
版权声明:本文为CSDN博主「老王123456789」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_43577616/article/details/115769477