容器组(Containers)
来源:互联网 发布:mac支持的大型网游 编辑:程序博客网 时间:2024/06/05 06:56
Group Box:组框。
Scroll Area:滚动区域。
Tool Box:工具箱。
Tab Widget:标签小部件。
Stacked Widget:堆叠部件。
Frame:帧。
Widget:小部件。
MdiArea:MDI区域。
Dock Widget:停靠窗体部件。
QAxWidget:封装Flash的ActiveX控件。
1.创建窗口
如果Widget未使用父级进行创建,则在显示时视为窗口或顶层Widget。由于顶层Widget没有父级对象类来确保在其不再使用时就删除,所以需要开发人员在应用程序中对其进行跟踪。
在本例中,使用QWidget创建和显示具有默认大小的窗口: QWidget *window = new QWidget();
window->resize(320, 240);
window->show();
QPushButton *button = new QPushButton(tr("Press me"), window); //(a)
button->move(100, 100);
button->show();
2.使用布局
通常,子Widget是通过使用布局对象在窗口中进行排列的,而不是通过指定位置和大小进行排列的。在此,构造一个并排排列的标签和行编辑框Widget:
QLabel *label = new QLabel(tr("Name:"));QLineEdit *lineEdit = new QLineEdit();QHBoxLayout *layout = new QHBoxLayout();layout->addWidget(label);layout->addWidget(lineEdit);window->setLayout(layout);构造的布局对象管理通过addWidget()函数提供Widget的位置和大小。布局本身是通过调用setLayout()提供给窗口的。
由于Widget可包含其他Widget,所以布局可用来提供按不同层次分组的Widget。这里,要在显示查询结果的表视图上方、窗口顶部的行编辑框旁,显示一个标签:
QLabel *queryLabel = new QLabel(tr("Query:"));QLineEdit *queryEdit = new QLineEdit();QTableView *resultView = new QTableView();QHBoxLayout *queryLayout = new QHBoxLayout();queryLayout->addWidget(queryLabel);queryLayout->addWidget(queryEdit);QVBoxLayout *mainLayout = new QVBoxLayout();mainLayout->addLayout(queryLayout);mainLayout->addWidget(resultView);window->setLayout(mainLayout);
0 0
- 容器组(Containers)
- 容器类(containers)
- 容器Containers
- 容器类(containers)
- 04 Containers容器
- Ext JS 容器Containers
- Python容器Containers
- Matlab绘图中的对象容器(Object Containers)
- docker 常用命令与常用容器(containers)环境
- STL associative containers(关联容器)
- 【ExtJS 4.x学习教程】(3)布局和容器(Layouts and Containers)
- Java swing 相关: Using Top-Level Containers(使用最上层容器)
- ExtJS 4 官方指南翻译:容器与布局(Layouts and Containers)
- #254 – 能够装载FlowDocument的容器(Types of Containers for Hosting a FlowDocument)
- ExtJS4 布局和容器:Layouts、Containers
- 五 关联式容器 associative containers
- 理解镜像(images)和容器(containers)
- Containers
- Nginx 负载均衡
- MJExtension中MJTypeEncoding.m报错问题
- View的requestDisallowInterceptTouchEvent对事件的影响
- Spring 攻略第003讲
- iOS 程序中的内存分配 栈区 堆区 全局区(静态存储区)
- 容器组(Containers)
- 如何触发<z:select>值改变事件
- 实验1:Problem A: 平面上的点和线——Point类、Line类 (I)
- Converting and transferring data
- MYSQL中replace into的用法
- android Fragment里的newInstance和构造函数
- cygwin的安装
- Find the Permutations [Uva 11077]
- activity 和 activitygroup 中的activity生命周期