• qt--QVBoxLayout


     1     QWidget *window = new QWidget();
     2     //创建按键,暂无配置slot
     3     QPushButton *button1 = new QPushButton(tr("one"));
     4     QPushButton *button2 = new QPushButton(tr("two"));
     5     QPushButton *button3 = new QPushButton(tr("three"));
     6     QPushButton *button4 = new QPushButton(tr("four"));
     7     QPushButton *button5 = new QPushButton(tr("five"));
     8     //垂直布局
     9     QVBoxLayout *layout = new QVBoxLayout;
    10     layout->addWidget(button1);
    11     layout->addWidget(button2);
    12     layout->addWidget(button3);
    13     layout->addWidget(button4);
    14     layout->addWidget(button5);
    15 
    16     window->setLayout(layout);
    17     window->show();

    //QVBoxLayout(垂直布局) QHBoxLayout(水平布局) 继承 QBoxLayout

     修改布局

     1 #include "widget.h"
     2 //#include "addDialog.h"
     3 #include <QtGui>
     4 
     5 Widget::Widget(QWidget *parent)
     6     : QWidget(parent)
     7 {
     8     createbigBox();
     9     createsmallBox();
    10 
    11     QWidget *window = new QWidget();
    12     //创建按键,暂无配置slot
    13 
    14 
    15 
    16     //垂直布局
    17     QVBoxLayout *mainLayout = new QVBoxLayout;
    18     mainLayout->addWidget(bigBox);
    19     mainLayout->addWidget(smallBox);
    20 
    21     window->setLayout(mainLayout);
    22     setWindowTitle(tr("layout-Demo"));
    23     window->show();
    24 
    25 }
    26 
    27 Widget::~Widget()
    28 {
    29     
    30 }
    31 
    32 void Widget::createbigBox()
    33 {
    34     bigBox = new QGroupBox(tr("bigGroupBox"));
    35 
    36     QPushButton *button1 = new QPushButton(tr("one"));
    37     //connect(button1,SIGNAL(clicked()),SLOT(open_One()));
    38     QPushButton *button2 = new QPushButton(tr("two"));
    39     QPushButton *button3 = new QPushButton(tr("three"));
    40     //水平布局
    41     QHBoxLayout *horizeLayout = new QHBoxLayout;
    42     horizeLayout->addWidget(button1);
    43     horizeLayout->addWidget(button2);
    44     horizeLayout->addWidget(button3);
    45 
    46     bigBox->setLayout(horizeLayout);
    47 }
    48 
    49 void Widget::createsmallBox()
    50 {
    51     smallBox = new QGroupBox(tr("smallGroupBox"));
    52 
    53     QPushButton *button4 = new QPushButton(tr("four"));
    54     QPushButton *button5 = new QPushButton(tr("five"));
    55 
    56     QHBoxLayout *toLayout = new QHBoxLayout;
    57     toLayout->addWidget(button4);
    58     toLayout->addWidget(button5);
    59 
    60     smallBox->setLayout(toLayout);
    61 }
    62 /*
    63 //槽函数
    64 void Widget::open_one()
    65 {
    66     Widget.widget;
    67 }
    68 */
  • 相关阅读:
    Postfix常用命令和邮件队列管理(queue)
    window7下面rabbitMQ安装配置过程详解
    RabbitMQ系列之消息确认机制
    全文检索:sphinx elasticsearch xunsearch 比较
    用SQL命令查看Mysql数据库大小
    部署Percona监控和管理--- PMM Server
    什么是MTU?为什么MTU值普遍都是1500?
    Mysql删除数据后,磁盘空间未释放的解决办法
    数据库索引
    visual studio 容器工具首次加载太慢 vsdbgvs2017u5 exists, deleting 的解决方案
  • 原文地址:https://www.cnblogs.com/Blue-Moniter4/p/9528702.html
Copyright © 2020-2023  润新知