1. In Qt, if you want to apply styles to the main window  itself, you must apply it to 

its central widget instead of the main window itself because the window is just
  a container.

2.设计时先添加垂直布局,再添加水平布局。

  固定控件大小时,把水平政策和垂直政策设为‘’‘fixed’,然后在mininum里输入大小。

3.布局 只有margin属性,可以 ‘’变形为’’ Widget,以求调整大小。

4 Qt的样式表跟CSS语法一样

5新建qt资源文件

To add a new .qrc file to our project, go to File | New File or Project. Then, select Qt under
the Files and Classes category and select Qt Resources File. After that, give it a name (that
is, resources) and click the Next button followed by the Finish button. The .qrc file will not
be created and automatically opened by Qt Creator。

6. Add Prefix   给资源文件添加目录

7.设置button的icon属性。改变iconsize来改变大小

 pixmap属性  :You will now see the logo size no longer follow the dimension you set previously and follow the actual dimension of the image instead. We cannot change its dimension because this is simply how pixmap works。

8要想不用pixmap的方式  border-image: url(:/images/logo.png); 

复制路径:To obtain the path of the image, right click the image name on the file list window 

and choose Copy path.

9pseudo states:

例如:

QPushButton:hover
{
color: white;
background-color: #66c011;
border-width: 0px;
border-radius: 3px;
}

  进一步自定义属性

QPushButton[pagematches=true]
{
color: white;
background-color: red;
border-width: 0px;
border-radius: 3px;
}

然后再mainwindow.cpp的构造函数下:

 ui->pushButton->setProperty("pagematches",true);

读属性: QObject::property().

10  sub-controls(用双引号引入)

QSpinBox::down-button
{ image: url(:/images/spindown.png);
subcontrol-origin: padding;
subcontrol-position: right bottom;
}

 

												

Qt5学习(1)的更多相关文章

  1. 我的QT5学习之路(目录)

    说明:本目录内容为自己学习的心得和记录,参考资料来源于网络,学习过程中多方汲取,如有错误,欢迎指正和批评. Qt开发相关文章目录 一.我的Qt学习之路系列 1.[笔记]我的Qt学习之路(一)——浅谈Q ...

  2. Qt5学习笔记(1)-环境配置(win+64bit+VS2013)

    Qt5学习笔记(1)-环境配置 工欲善其事必先-不装-所以装软件 久不露面,赶紧打下酱油. 下载 地址:http://download.qt.io/ 这个小网页就可以下载到跟Qt有关的几乎所有大部分东 ...

  3. 我的QT5学习之路(三)——模板库、工具类和控件(下)

    一.前言 作为第三篇的最后一部分,我们来看一下Qt的控件,谈到控件,就会让人想到界面的美观性和易操作性,进而想到开发的便捷性.作为windows界面开发的MFC曾经是盛行了多少年,但是其弊端也随着其他 ...

  4. 我的QT5学习之路(一)——浅谈QT的安装和配置

    一.前言 说到Qt,不能不说到C++,这门伟大的语言.因为其面向对象的编程思想和陡峭的学习曲线,一开始学习起来很是吃力.Qt从QT4开始基本封装了很多C++的工具库和界面库,而且支持跨平台,这是它最大 ...

  5. QT5学习记录(一)

    学习环境:Windows10 + QT5.13 + QT Creater4.9.1(2019-08-10 22:02:30) 1.基本工程创建操作 常规操作创建画面,可选择QDialog.MainWi ...

  6. qt5学习目录

    qt5下载与安装,VS2017的环境配置                                                                               q ...

  7. 我的QT5学习之路(二)——第一个程序

    一.前言 “工欲善其事,必先利其器”,上一节,我介绍了Qt的安装和配置方法,搭建了基本的开发平台.这一节,来通过一个简单的例子来了解Qt的编程样式和规范,开始喽~~~ 二.第一个程序——Hello W ...

  8. Qt5学习(2)

    1.学习了qt quick application 这是一种跟application不同的设计方式.主要就是靠“拖拖拽拽”,然后设置属性(颜色,大小),布局(margins等),然后要注意控件的从属关 ...

  9. Qt5学习记录:QString与int值互相转换

    1)QString转int 直接调用toInt()函数 例: QString str("100"); int tmp = str.toInt(); 或者: bool ok; QSt ...

  10. Qt5学习笔记(基础)

    按钮 #include <QApplication> /*应用程序抽象类*/ #include <QWidget> //窗口类 #include <QPushButton ...

随机推荐

  1. angularJS $q

    1.$q $q是Angular的一种内置服务,它可以使你异步地执行函数,并且当函数执行完成时它允许你使用函数的返回值(或异常). 2.defer defer的字面意思是延迟, $q.defer()   ...

  2. 手动实现如何从H264流中提取SPS/PPS信息

    1,代码比较简单,可以直接用了.流的第一个NALU一定是SPS void get_sps_pps_nalu(uint8_t *data, int len, std::vector<uint8_t ...

  3. oracle comment on的用法

    转:http://www.2cto.com/database/201109/106249.html   oracle中用comment on命令给表或字段加以说明,语法如下:COMMENT ON  { ...

  4. Pytorch Bi-LSTM + CRF 代码详解

    久闻LSTM + CRF的效果强大,最近在看Pytorch官网文档的时候,看到了这段代码,前前后后查了很多资料,终于把代码弄懂了.我希望在后来人看这段代码的时候,直接就看我的博客就能完全弄懂这段代码. ...

  5. Array.from()类数组转化为数组的用法

    类数组对象转化为数组 let arrayLike = { '0': 'a', '1': 'b', '2': 'c', length: 3 }; let arr = Array.from(arrayLi ...

  6. P1075 语句解析

    题目描述 一串长度不超过 255 的 PASCAL 语言代码,只有 a,b,c 3 个变量,而且只有赋值语句,赋值只能是一个一位的数字或一个变量,每条赋值语句的格式是 [变量]:=[变量或一位整数]; ...

  7. 纯CSS绘制的图形一览

    整理网上一些使用纯CSS绘制的图形示例~~纯属抄袭,哈哈...仅仅是为了自己以后查看! Square(正方形) #square { width: 100px; height: 100px; backg ...

  8. 2019-3-1-C#-double-好用的扩展

    title author date CreateTime categories C# double 好用的扩展 lindexi 2019-3-1 9:19:5 +0800 2018-05-15 10: ...

  9. CF1045G AI robots

    CF1045G AI robots 题目大意就不说了 这道题可以用CDQ分治做 但是,如何选择CDQ分治的维度一直是CDQ分治的难点所在 这道题我们有三种选择 1.让智商高的数智商低的 2.让看的近的 ...

  10. LeetCode150_Evaluate Reverse Polish Notation评估逆波兰表达式(栈相关问题)

    题目: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are+, ...