欢迎访问Ningto's博客

Menu
  • 首页
  • 归档
  • 关于
  • 必应壁纸
  • 我的网盘
Menu

QLayout: Attempting to add QLayout

最后更新 2017-06-17 15:58:39   阅读量 3252

QLayout: Attempting to add QLayout , which already has a layout

出现这个警告的原因是一个QWidget作为了多个QLayout的parent,一个QWidget应该只有一个main layout,将其它子widget或者layout增加到main layout中,如下代码:

    QWidget *x = new QWidget(this);
    QHBoxLayout *h1 = new QHBoxLayout(x);
    QHBoxLayout *h2 = new QHBoxLayout(x);

会出现警告:

QLayout: Attempting to add QLayout "" to QWidget "", which already has a layout

解决方法:

    QWidget *x = new QWidget(this);
    QHBoxLayout *h1 = new QHBoxLayout(x);
    QHBoxLayout *h2 = new QHBoxLayout();
    h1->addLayout(h2);

或者给h2指定其它的widget作为parent。

(转载本站文章请注明作者和出处:泞途 - ningto.com)

下一篇 – C++11 thread
上一篇 – Redis常见问题和解答

  • Qt
  • tujiaw@163.com

    推荐文章

    CentOS6 yum The requested URL returned error: 404 Not Found

    CentOS7 U盘安装 No Caching mode page found

    golang 单例模式

    CentOS7 systemctl service

    golang 中介者模式

    CentOS7 debuginfo-install

    win32应用程序内存不足

    ntscreenshot截图工具马赛克功能实现

    标签云

    MongoDB Database Mac Node.js Tools Product Mobile IOS Web Boost Bug React Shell Life C/C++ Design Android Java Go Tips Windows Javascript Qt Linux MQ
    Copyright © 2016 Welcome To Ningto Blog | 鄂ICP备17003086号