Qt4--FormLayout
来源:互联网 发布:ubuntu设置网络连接 编辑:程序博客网 时间:2024/05/19 13:44
FormLayout显然对于Form非常适合。
QFormLayout *formLay=new QFormLayout;
QLineEdit *name=new QLineEdit;
QLineEdit *email=new QLineEdit;
QLineEdit *address=new QLineEdit;
formLay->addRow(tr("&Name:"),name);
formLay->addRow(tr("&Email:"),email);
formLay->addRow(tr("&Address:"),address);
setLayout(formLay);
仅需要这些代码就可以显示如下:
formLay->setLabelAlignment(Qt::AlignRight);
formLay->setRowWrapPolicy(QFormLayout::WrapAllRows);(默认的是QFormLayout::DontWrapAllRows)之后变为
另外注意到tr("&Name:"),加这个'&'是什么意思呢,实际上在为一个Label setBuddy时必须加&,在FormLayout中自动把LineEdit设为Label的Buddy了。如果使用其他Layout需要用下面代码显示指定Buddy:
QLineEdit *nameEd = new QLineEdit(this); QLabel *nameLb = new QLabel("&Name:", this); nameLb->setBuddy(nameEd); QLineEdit *phoneEd = new QLineEdit(this); QLabel *phoneLb = new QLabel("&Phone:", this); phoneLb->setBuddy(phoneEd);
设置Buddy有神马用呢?当你按Alt+A时Address对应的LineEdit自动获得Focus。
另外只有Label才可以有Buddy
Layout之间可以相互嵌套,Vlayout->addLayout(hLayout);
但是注意FormLayout没有addLayout,只有addChildLayout,并且addChildLayout的访问权限还是protected。
- Qt4--FormLayout
- Qt4--FormLayout
- FormLayout(一)
- JGoodies FormLayout
- FormLayout的个人理解
- SWT中的FormLayout
- SWT中的FormLayout
- FormLayout 布局认识
- FormLayout实现自适应窗口
- formlayout布局,datetime演示
- Ext.layout.FormLayout
- SWT中的FormLayout
- Swing界面布局(FormLayout)
- 自定义布局管理器-FormLayout
- 自定义布局管理器-FormLayout
- SWT中的FormLayout
- swing的jgoodies FormLayout
- Qt FormLayout 使用
- 嵌入式Qtopia-2.2.0开发环境的搭建和使用
- 函数指针和指针函数
- Ubuntu10.04上安装Oracle10gR2
- Qt-4.7开发环境的搭建
- Ubuntu上编译安装Qt4.7的QOCI驱动
- Qt4--FormLayout
- linux下用dnw烧写文件系统
- ubuntu上安装CLucene
- 利用不相交集画迷宫
- command>/dev/null 2>&1
- 用栈计算表达式
- 由二叉树的先序中序推出后序
- 最大子序列、最长递增子序列、最长公共子串、最长公共子序列、字符串编辑距离
- 开源软件许可协议简介