当前位置: 代码迷 >> QT开发 >> QT解决办法
  详细解决方案

QT解决办法

热度:41   发布时间:2016-04-25 04:37:28.0
QT

  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)去掉
  相关解决方案