hlayout1 = new QHBoxLayout(this);
hlayout1 -> addWidget(previousbutton);
hlayout1 -> addWidget(playbutton);
hlayout1 -> addWidget(stopbutton);
hlayout1 -> addWidget(nextbutton);
hlayout1 -> addWidget(volumeslider);
hlayout2 = new QHBoxLayout(this);
hlayout2 -> addWidget(hslider);
hlayout2 -> addWidget(timeedit);
hlayout3=new QHBoxLayout(this);
hlayout3 -> addWidget(openbutton);
hlayout3 -> addWidget(listbutton);
hlayout3 -> addWidget(lrcbutton);
vlayout = new QVBoxLayout(this);
vlayout ->addLayout(hlayout1);
vlayout ->addLayout(hlayout2);
vlayout ->addLayout(hlayout3);
widget = new QWidget(this);
widget -> setLayout(vlayout);
setCentralWidget(widget);
调试结果为:
&"warning: GDB: Failed to set controlling terminal: Invalid argument\n"
QLayout: Attempting to add QLayout "" to MainWindow "", which already has a layout
QLayout: Attempting to add QLayout "" to MainWindow "", which already has a layout
QLayout: Attempting to add QLayout "" to MainWindow "", which already has a layout
QLayout: Attempting to add QLayout "" to MainWindow "", which already has a layout
运行都正常,就是这些显示红色警报,求指导啊
------解决方案--------------------
layout可以不用指定父
------解决方案--------------------
hlayout1 = new QHBoxLayout(this);
(this)去掉