QT笔记-布局
1 QT中使用布局器QLayout布局
2自动计算各个空间的大小和位置 采用的既定policy策略来调整子窗口的大小和位置
3QHBoxLayout横向布局 QVBoxLayout纵向布局
- QHBoxLayout ( QWidget * parent, int margin = 0, int spacing = -1, const char * name = 0 )
- QHBoxLayout ( QLayout * parentLayout, int spacing = -1, const char * name = 0 )
- QHBoxLayout ( int spacing = -1, const char * name = 0 )
使用三部曲:(1)创建控件对象(2)创建布局器(3)使用布局器
Mywin.h
#ifndef MYWIN_H
#define MYWIN_H #include <QWidget> // 添加头文件
#include <QVBoxLayout>
#include <QLineEdit>
#include <QPlainTextEdit> class MyWin : public QWidget
{
Q_OBJECT public:
MyWin(QWidget *parent);
~MyWin(); private:
QLineEdit* m_lineEdit;
QPlainTextEdit* m_textEdit; }; #endif // MYWIN_H
Mywin.cpp
#include "MyWin.h" MyWin::MyWin(QWidget *parent)
: QWidget(parent)
{
// 创建控件对象
m_lineEdit = new QLineEdit(this);
m_textEdit = new QPlainTextEdit(this); // 创建布局器
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addWidget(m_lineEdit); // 将第一个box添加到布局器
layout->addWidget(m_textEdit); // 将第二个box添加到布局器 // 使用布局器
this->setLayout(layout);
} MyWin::~MyWin()
{ }
QT笔记-布局的更多相关文章
- Qt之布局管理--基本布局
Qt提供的布局类以及他们之间的继承关系QLayout-----QGirdLayout | ---QBoxLayout----QHBoxLayout | --QVBoxLayout----------- ...
- Qt Quick 布局演示
于 Qt Widgets 于,我们经常使用许多布局管理器来管理界面 widgets . 于 Qt Quick 实际上,有两个相关的管理和布局库,所谓集 Item Positioner ,所谓集 Ite ...
- Bootstrap学习笔记-布局
Bootstrap学习笔记-布局 默认是响应式布局,就是你在改变页面的时候也不会出现乱的现象. <html><head> <meta charset="utf- ...
- Qt之布局管理器
简述 Qt的布局系统提供了一个简单的和强有力的方式,来自动排列窗口子控件布局. 所有QWidget子类可以使用布局来管理他们的子控件.QWidget::setLayout()函数可以为一个控件布局.当 ...
- Qt Designer布局预览正常,代码调用时所有控件堆在一起
一.实验环境 1.Windows10x64 2.anaconda4.6.9 + python3.7.1(anaconda集成,不需单独安装) 3.pyinstaller3.5 二.问题描述 1.Qt ...
- Qt Quick 布局介绍
在 Qt Quick 中有两套与布局管理相关的类库,一套叫作 Item Positioner(定位器),一套叫作 Item Layout(布局). 定位器包括 Row(行定位器).Column(列定位 ...
- Qt 窗体布局 good
布局相关对象及简介 窗体上的所有的控件必须有一个合适的尺寸和位置.Qt提供了一些类负责排列窗体上的控件,主要有:QHBoxLayout,QVBoxLayout,QGridLayout,QStackLa ...
- Qt基本布局(QLayout)
概述 Qt提供了QHBoxLayout类(水平排列布局),QVBoxLayout类(垂直排列布局),QGridLayout类(网格排列布局)等基本布局管理.它们之间的继承关系如下图 布局中常用的方法有 ...
- Qt笔记之使用设计器自定义窗口标题栏
1.在窗口显示之前,设置WindowFlags为FramelessWindowHint,以产生一个没有边界的窗口 例如 Widget::Widget(QWidget *parent) : QWidge ...
随机推荐
- Java有几种线程池?
Java通过Executors提供四种线程池,分别为:newCachedThreadPool创建一个可缓存线程池,如果线程池长度超过处理需要,可灵活回收空闲线程,若无可回收,则新建线程newFixed ...
- HDU 6370 dfs+并查集
Werewolf Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- 动态规划:Monkey and Banana
Problem Description A group of researchers are designing an experiment to test the IQ of a monkey. T ...
- Javaee的霸主之spring系列
Spring 顶级框架 谈及微服务,作为当前主流的企业框架Spring,它提供了一整套相关的顶级项目,能让开发者快速的上手实现自己的应用,今天就介绍下Spring旗下各个顶级项目: Spring IO ...
- 收集的一些Redis操作技巧教程
redis(1).redis入门 redis(2).redis数据类型 redis(3).基于jedis.spring-data-redis 连接操作redis redis(4).基于redis 构建 ...
- java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet
新建Maven 项目的时候报错: java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet ...
- Spring Boot项目错误:Error parsing lifecycle processing instructions
pom.xml文件错误:Error parsing lifecycle processing instructions 解决方法:清空.m2/repository下的所有依赖文件,重新下载即可解决该问 ...
- Web.config的system.webServer节点与system.web的区别
Web.config 文件中的 system.webServer 节用于指定适用于 Web 应用程序的 IIS 7.0 设置.system.WebServer 是 configuration 节的子级 ...
- Java8初体验(二)Stream语法详解(转)
本文转自http://ifeve.com/stream/ Java8初体验(二)Stream语法详解 感谢同事[天锦]的投稿.投稿请联系 tengfei@ifeve.com上篇文章Java8初体验(一 ...
- linux 下的特殊文件 /dev/null 和 /de/zero
生成一个100Mb的文件 : time dd of=2Gb.file if=/dev/zero bs=1024 count=100000 ubuntu 下测试磁盘的读写性能: 测试写: time d ...