- 浏览: 3420983 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
sonichy:
Qt5改动很多,要改改了。
基于QItemDelegate的例子1 SpinBoxDelegate -
我的主页6:
楼主,2.2子查询的分页方式:SELECT * FROM ar ...
Mysql 分页语句Limit用法 -
liguoqi:
非常感谢楼主的用心指导,工具以及图片例子都提供了 赞!
两款免费DCIOM 图像浏览软件介绍和DICOM图像例子供下载 -
liguoqi:
问下这个图片怎么解压损坏呀
两款免费DCIOM 图像浏览软件介绍和DICOM图像例子供下载 -
liguoqi:
楼主讲解的非常详细,还附带工具和图片例子,非常感谢
两款免费DCIOM 图像浏览软件介绍和DICOM图像例子供下载
主要包括QBoxLayout、和QGridLayout以及QFormLayout等的参数类似。
我主要说明一下QGridLayout在QtDesigner中它的属性的意义,以及QFormLayout的部分属性
一、QGridLayout属性介绍
1、QGridlayout以方格的形式管理窗口部件,先看QGridLayout的属性,如下图
2、各个参数的介绍
layoutLeftMargin ...至layoutBottomMargin在ui_MainWindow.h中自动生成的代码是:
gridLayout->setContentsMargins(20, 10, 10, 10);
学过CSS都知道,这是设置一个元素所有外边距的宽度,或者设置各边上外边距的宽度
On most platforms, the margin is 11 pixels in all directions.
HorizontalSpacing...至VerticalSpacing在ui_MainWindow.h中自动生成的代码是:
gridLayout->setHorizontalSpacing(6);
gridLayout->setVerticalSpacing(6);
这是设置两个控件之间的水平和竖直距离
LayoutRowStretch在ui_MainWindow.h中自动生成的代码是:
gridLayout->setRowStretch(0, 1);
gridLayout->setRowStretch(1, 1);
gridLayout->setRowStretch(2, 1);
表示在第0行、第1行、第2行 在竖直方向的空间比例分配,大家稍微改一下参数就能看出来效果
LayoutColumnStretch在ui_MainWindow.h中自动生成的代码是:
gridLayout->setColumnStretch(1, 1);
表示设置第0列、第1列两者在水平方向的空间比例分配。
LayoutRowMinimumHeight在ui_MainWindow.h中自动生成的代码是:
gridLayout->setRowMinimumHeight(0, 1);
gridLayout->setRowMinimumHeight(1, 2);
gridLayout->setRowMinimumHeight(2, 3);
表示在第0行、第1行、第2行的最小高度是1pixels,2pixels,3pixels
LayoutColumnMinimumWidth在ui_MainWindow.h中自动生成的代码是:
gridLayout->setColumnMinimumWidth(0, 4);
gridLayout->setColumnMinimumWidth(1, 5);
表示设置第0列、第1列的最小宽度是4pixels、5pixels
LayoutSizeConstraint在ui_MainWindow.h中自动生成的代码是:
gridLayout->setSizeConstraint(QLayout::SetDefaultConstraint);
This property holds the resize mode of the layout.看下表
enum QLayout::SizeConstraint
The possible values are:
QLayout::SetDefaultConstraint | 0 | The main widget's minimum size is set to minimumSize(), unless the widget already has a minimum size. |
QLayout::SetFixedSize | 3 | The main widget's size is set to sizeHint(); it cannot be resized at all. |
QLayout::SetMinimumSize | 2 | The main widget's minimum size is set to minimumSize(); it cannot be smaller. |
QLayout::SetMaximumSize | 4 | The main widget's maximum size is set to maximumSize(); it cannot be larger. |
QLayout::SetMinAndMaxSize | 5 | The main widget's minimum size is set to minimumSize() and its maximum size is set tomaximumSize(). |
QLayout::SetNoConstraint | 1 |
The widget is not constrained.
|
QFormLayout属性介绍
1、QFormLayout类管理输入型控件和它的label组成的那些form表格,包括它的界面参数如下图
2、界面中对应的代码如下表,
formLayout = new QFormLayout(widget1); formLayout->setSpacing(6); formLayout->setContentsMargins(11, 11, 11, 11); formLayout->setObjectName(QString::fromUtf8("formLayout")); formLayout->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow); formLayout->setRowWrapPolicy(QFormLayout::DontWrapRows); formLayout->setContentsMargins(0, 0, 0, 0); label_4 = new QLabel(widget1); label_4->setObjectName(QString::fromUtf8("label_4")); formLayout->setWidget(0, QFormLayout::LabelRole, label_4); lineEdit = new QLineEdit(widget1); lineEdit->setObjectName(QString::fromUtf8("lineEdit")); formLayout->setWidget(0, QFormLayout::FieldRole, lineEdit); label_5 = new QLabel(widget1); label_5->setObjectName(QString::fromUtf8("label_5")); formLayout->setWidget(1, QFormLayout::LabelRole, label_5); comboBox = new QComboBox(widget1); comboBox->setObjectName(QString::fromUtf8("comboBox")); formLayout->setWidget(1, QFormLayout::FieldRole, comboBox);
3、其中值得一说的是:LayoutFieldGrowthPolicy属性
enum QFormLayout::FieldGrowthPolicy
This enum specifies the different policies that can be used to control the way in which the form's fields grow.
QFormLayout::FieldsStayAtSizeHint | 0 | The fields never grow beyond their effective size hint. This is the default forQMacStyle. |
QFormLayout::ExpandingFieldsGrow | 1 | Fields with an horizontal size policy of Expanding or MinimumExpanding will grow to fill the available space. The other fields will not grow beyond their effective size hint. This is the default policy for Plastique. |
QFormLayout::AllNonFixedFieldsGrow | 2 | All fields with a size policy that allows them to grow will grow to fill the available space. This is the default policy for most styles. |
4、还有一个属性值得说:LayoutRowWrapPolicy
This property holds the way in which the form's rows wrap.
//这个属性设置了表格如何排版各个元素
If you want to display each label above its associated field (instead of next to it), set this property to WrapAllRows.
//如果你想把每个标签放在相关字段的上方,而不是和它相邻,就设置这个属性值为WrapAllRows。
enum QFormLayout::RowWrapPolicy
This enum specifies the different policies that can be used to control the way in which the form's rows wrap.
QFormLayout::DontWrapRows | 0 | Fields are always laid out next to their label. This is the default policy for all styles except Qt Extended styles and QS60Style. |
QFormLayout::WrapLongRows | 1 | Labels are given enough horizontal space to fit the widest label, and the rest of the space is given to the fields. If the minimum size of a field pair is wider than the available space, the field is wrapped to the next line. This is the default policy for Qt Extended styles and andQS60Style. |
QFormLayout::WrapAllRows | 2 | Fields are always laid out below their label. |
发表评论
-
Qt官网变更【2012】
2012-09-21 19:30 4139Qt最近被Digia完全收购,诺基亚这两年的不理不睬,没有魄力 ... -
【转】QT实现不规则窗体
2012-09-21 18:50 4906看到好文章,收藏一下: 看到网上有很多不规则窗体的实现 ... -
Qt应用程序如何使用DCMTK类库进行二次开发DICOM数据传输
2012-09-13 09:35 0参考文章: 1、Using DCMTK with ... -
【转】将QT开发的界面程序封装成DLL,在VC中成功调用
2012-09-11 10:33 21001最近手头的一个项目需要做一个QT界面,并且封装成DLL,然后 ... -
诺基亚挥别Qt,转手给Digia
2012-09-11 09:37 2779一家总部位于芬兰的IT业务供应商Digia今天宣布,已经签署了 ... -
Qt多线程间信号槽传递非QObject类型对象的参数
2012-09-07 15:29 21201一、以前就发现过这个问题: 在Qt项目中,有时候为了 ... -
QT样式表(QStyleSheet)
2012-08-17 10:37 17804QT样式表 (QStyleSheet) 作者:刘旭晖 ... -
FinalData磁盘文件恢复工具(绿色破解版)
2012-08-02 13:28 8478FinalData磁盘文件恢复工具(绿色破解版),使用起来很方 ... -
Eclipse Qt开发环境的建立【转】
2012-08-01 11:15 43171.下载Eclipse目前Eclipse+CDT已经可以 ... -
汽车辐射监测系统-Qt开发
2012-07-25 16:18 4635最近晚上抽空忙了两个月,才把一个小系统做完。虽然做的不是太完 ... -
Qt做发布版,解决声音和图片、中文字体乱码问题
2012-07-14 16:02 4809Qt做发布版,解决声音和图片、中文字体乱码问题 ... -
QTableView使用中的疑问,如何及时显示操作Model后的结果?
2012-06-01 14:52 0最终的解决方法:我正 ... -
【转】Qt QTableview使用
2012-06-01 09:49 9616QTableWidget是QT程序中常用的显示数 ... -
QTableView双击 单机事件信号
2012-06-01 09:47 22897双击QTableView的行,获取该行数据 代码 ... -
QMessageBox改变大小
2012-05-31 15:33 8366创建一个QMessageBox: QMessageBo ... -
更新QTableView中的进度条状态
2012-05-30 14:37 14743前段时间,我接触了,如何在一个QTableView中加入一个控 ... -
QThread 线程暂停 停止功能的实现
2012-05-29 11:56 12115为了实现Qt中线程的暂停运行,和停止运行的控制功能 需要在设 ... -
QT环境变量
2012-05-28 18:53 5539不知道为啥同事有台电脑,装完Qt-VS2008库,和VS Ad ... -
广告光
2012-05-24 18:33 0盈创广告联盟 http://www.yo114.cn/ ... -
Test
2012-05-24 18:22 2133Test<IMG SRC="cf08e32c2 ...
相关推荐
Qt工具中QLayout的应用例子,下载后可看到有4个小例子,分别是: 1、QFormLayout 2、QGridLayout 3、QHBoxLayout 4、QVBoxLayout
QT5实现的卡片布局,基于QLayout的CardStackLayout,实现动画效果。
qt video,从基础开始,第7部分,一共14部分,使用vs2015的addin作为教学工具,很不错的。
电子-BK3431QLAYOUT指南.pdf,物联网/通信技术蓝牙通信
每个小部件通过sizeHint和sizePolicy属性将其大小要求报告给布局,并且该布局相应地分配可用空间。 Qt Designer是一个强大的工具,用于在布局中交互式创建和排列小部件。 第7章讲述了一些窗口部件,当时往界面上...
1.2.5 QLayout类的大小约束属性的取值 1.3 可扩展窗口 1.4 分裂器(QSplitter) 2. 设置伙伴(buddy) 3. 设置Tab键顺序 4. Qt Creator中的定位器 ———————————————— 版权声明:本文为CSDN博主「...
qt 最基础 最详细的 layout 基本布局 源代码 很适合基础薄弱的下载,学习这个之后你会对qt有很大的了解
3. 控件除了Bar提供了设置高度接口外,其他都不会提供设置Size、Width、Height等函数接口,因为控件使用了自适应宽高的架构,如果去设置了这些属性会破坏控件的结构 导致出现滚动条后还需要去计算各个控件的宽高等 ...
Qt5开发及实例 第3章 Qt 5布局管理
本书详细介绍了Qt的基础知识和GUI编程应用,举例翔实,内容全面,基本涵盖了Qt编程的各个方面。全书共分3篇21章,包括Qt GUI编程的基础知识(对话框、基础窗口部件、程序主窗口、布局管理),中级编程(2D绘图、拖放...
VC++(MFC),UI布局管理器。功能类似QT的QLayout
\5.1 Qt布局管理器——QLayout 121 \5.1.1 Qt布局管理器简介 121 \5.1.2 布局管理器及窗口部件大小策略 \5.1.2 的应用 125 \5.2 分裂器部件QSplitter 132 \5.3 栈部件QStackedWidget 134 \5.4 工作空间部件...
\5.1 Qt布局管理器——QLayout 121 \5.1.1 Qt布局管理器简介 121 \5.1.2 布局管理器及窗口部件大小策略 \5.1.2 的应用 125 \5.2 分裂器部件QSplitter 132 \5.3 栈部件QStackedWidget 134 \5.4 工作空间部件...
测试QLayout和QLabel加载图片的demo MyDebug << "label1->size" << label1->size(); QString path = QCoreApplication::applicationDirPath(); path = QFileDialog::getOpenFileName(this, "open image", path, ...
基础部分:介绍Qt编程环境安装,编程环境使用技巧,及以Qt开发起点界面开发必不可少的UI控件使用编程为引导做到让学习者由生变熟的转化过程。进阶部分:主要以一个例子开始讲解实际开发过程所需技能要达到的成度即...
#include <QLayout> #include int main(int argc, char *argv[]) { QApplication a(argc, argv) QWidget* pWnd = new QWidget(); QPushButton* pBtn = new QPushButton(QPushButton::tr("Test Translate")) ...
5.1 Qt布局管理器——QLayout 5.2 分裂器部件Qsplitter 5.3 栈部件Qstackedwidget 5.4 工作空间部件QWorkspace 5.5 多文档区部件QMdiArea 5.6 小结 中级篇 第6章 2D绘图 第7章 拖放操作和剪贴机 第8章 文件处理 第9...
5.1 Qt布局管理器——QLayout 5.2 分裂器部件Qsplitter 5.3 栈部件Qstackedwidget 5.4 工作空间部件QWorkspace 5.5 多文档区部件QMdiArea 5.6 小结 中级篇 第6章 2D绘图 第7章 拖放操作和剪贴机 第8章 文件处理 第9...
5.1 Qt布局管理器——QLayout 5.2 分裂器部件Qsplitter 5.3 栈部件Qstackedwidget 5.4 工作空间部件QWorkspace 5.5 多文档区部件QMdiArea 5.6 小结 中级篇 第6章 2D绘图 第7章 拖放操作和剪贴机 第8章 文件处理 第9...
代码如下:#include <QApplication>#include <QLabel>#include <QDate>#include <QLayout>int main(int argc, char *argv[]){ QApplication a(argc, argv); QLabel *label = new QLabel; QDate currentDate = ...