当前位置:首页 > 嵌入式 > 嵌入式软件
[导读]QHBoxLayout* toolLayout = new QHBoxLayout; toolLayout->addWidget(pushButton_1); toolLayout->addWidget(pushButton_2); toolLayout->addStretch(); toolLayout->addWidget(pushButton_3);

 

1. [代码][C/C++]代码     

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <QApplication>
#include "qtestdialog.h"
  
TestDialog::TestDialog(QWidget *parent)
    : QDialog(parent)
{
    pushButton_1 = new QPushButton(tr("字体"));
    pushButton_2 = new QPushButton(tr("大小"));
    pushButton_3 = new QPushButton(tr("消息记录"));
  
    QHBoxLayout* toolLayout = new QHBoxLayout;
    toolLayout->addWidget(pushButton_1);
    toolLayout->addWidget(pushButton_2);
    toolLayout->addStretch();
    toolLayout->addWidget(pushButton_3);
  
  
    pushButton_4 = new QPushButton(tr("关闭"));
    pushButton_5 = new QPushButton(tr("发送"));
    QHBoxLayout* buttomLayout = new QHBoxLayout;
    buttomLayout->addStretch();
    buttomLayout->addWidget(pushButton_4);
    buttomLayout->addWidget(pushButton_5);
  
  
    textEdit_1 = new QTextEdit;
    textEdit_2 = new QTextEdit;
    textEdit_2->setMaximumHeight(90);
    QVBoxLayout* leftlayout = new QVBoxLayout;
    leftlayout->addWidget(textEdit_1);
    leftlayout->addLayout(toolLayout);
    leftlayout->addWidget(textEdit_2);
    leftlayout->addLayout(buttomLayout);
  
  
  
    textEdit_3 = new QTextEdit;
    textEdit_3->setMaximumWidth(100);
    QVBoxLayout* rightlayout = new QVBoxLayout;
    rightlayout->addWidget(textEdit_3);
  
    QHBoxLayout* toplayout = new QHBoxLayout;
    toplayout->addLayout(leftlayout);
    toplayout->addLayout(rightlayout);
  
  
    QHBoxLayout *mainLayout = new QHBoxLayout;
    mainLayout->addLayout(toplayout);
    setLayout(mainLayout);
  
  
}

2. [代码][C/C++]代码     

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#ifndef QTESTDIALOG_H
#define QTESTDIALOG_H
  
#include <QDialog>
#include <QTextEdit>
#include <QPushButton>
#include <QLayout>
  
class TestDialog:public QDialog
{
    Q_OBJECT
public:
    TestDialog(QWidget *parent = 0);
private:
    QTextEdit* textEdit_1;
    QTextEdit* textEdit_2;
    QTextEdit* textEdit_3;
    QPushButton* pushButton_1;
    QPushButton* pushButton_2;
    QPushButton* pushButton_3;
    QPushButton* pushButton_4;
    QPushButton* pushButton_5;
};

3. [代码][C/C++]代码     

1
2
3
4
5
6
7
8
9
10
#include <QApplication>
#include "QTestDialog.h"
  
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    TestDialog* tdialog = new TestDialog;
    tdialog->show();
    return a.exec();
}

4. [图片] qt布局.png    

本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除( 邮箱:macysun@21ic.com )。
换一批
延伸阅读
关闭