欢迎访问Ningto's博客

Menu
  • 首页
  • 归档
  • 关于
  • 书签
  • 必应壁纸
  • IT聚合
  • 工具
    • 我的工具列表
    • 我的网盘
    • 必应每日壁纸API
    • Html转Markdown
    • 仙尘光标
Menu

QLayout: Attempting to add QLayout

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

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
上一篇 – javascript怎么实现类似如C++函数中使用静态数据

  1. Qt

toningto@outlook.com

标签云

Life Android Javascript Python Windows Product Go Tools Java MQ Qt Node.js Tips Shell Design MongoDB Others Mac Mobile React C/C++ Web Boost Linux IOS Bug Database

推广链接

【腾讯云】云产品限时秒杀,爆款1核2G云服务器,首年99元

多谢支持,用了好几年,服务很稳定支持多设备!

其他

文章RSS

Copyright © 2016 Welcome To Ningto Blog | 鄂ICP备17003086号-2