在QT的IDE下,编写一个自定义布局。

 #include<QApplication>
#include<QWidget>
#include<QSpinBox>
#include<QSlider>
#include<QHBoxLayout> int main (int argc,char *argv[])
{
QApplication app(argc, argv);
QWidget * window = new QWidget;
window->setWindowTitle("ENTER your age");
QSpinBox *spinBox = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);
spinBox->setRange(,);
slider->setRange(,);
QObject::connect(slider,SIGNAL(valueChanged(int)),spinBox,SLOT(setValue(int)));
QObject::connect(spinBox,SIGNAL(valueChanged(int)),slider,SLOT(setValue(int)));
spinBox->setValue();
QHBoxLayout*layout=new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
window->setLayout(layout);
window->show();
return app.exec();
}

在qt creater 运行结果,如下

用两个信号槽进行连接,QHBoxLayout是一个水平布局,按照从左向右的方向添加。

这两个信号槽不会无限递归,因为回调回来的int值相同,就不会继续发生信号了。

QT的三个布局,QHBoxLayout,水平布局,从左向右。

QVBoxLayout,垂直布局,从上到下。

QGridLayout,网状布局。

layout使用addWidget加载组件,使用addLayout添加子布局。

最新文章

  1. SEED实验系列文章目录
  2. try catch中用了 Response.Redirect 引发的线程异常终止
  3. android Context 持有导致的内存泄漏
  4. PHP开发环境配置~Windows 7 IIS
  5. struts之动态方法调用使用通配符
  6. 轻量级富文本编辑器wangEditor源码结构介绍
  7. NOIP2015 运输计划(bzoj4326)
  8. hibernate关联映射学习
  9. SublimeText为啥选择Python开发extension
  10. JSON代码小计
  11. 在Main中定义student的结构体,进行年龄从大到小依次排序录入学生信息。(结构体的用法以及冒泡排序)
  12. uiZjs入门
  13. C#传递参数
  14. I Love You Too HDU 2816
  15. Filter简单介绍
  16. 每天进步一点点——Linux磁盘管理LVM与RAID
  17. IOS7配置自动布局的约束
  18. Attribute(特性)与AOP
  19. Python Tkinter小试
  20. python 使用selenium模块实现自动搜索百度百科词条(模拟人工搜索)

热门文章

  1. 解析ES6 Promise
  2. Flyway-使用步骤
  3. html的列表
  4. 深入理解JavaScript系列(47):对象创建模式(上篇)
  5. Shiro登录校验
  6. number_formate 货币金额或数量格式化
  7. css样式的优先顺序
  8. 纯css面板插件,自适应,多样式
  9. iis添加共享目录为虚拟目录
  10. Sql-exec