zoukankan      html  css  js  c++  java
  • Qt5学习(1)

    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- 0px;
     border-radius: 3px;
    }
    

      进一步自定义属性

    QPushButton[pagematches=true]
    {
     color: white;
     background-color: red;
     border- 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;
    }

     

    
    
    
  • 相关阅读:
    利用条件信号量设计读写锁
    高效编程之互斥锁和自旋锁的一些知识
    高效编程之指针跳转的影响
    高效编程之cache命中对于程序性能的影响
    SQL Server中使用自定义指定顺序排序
    Vue使用,异步获取日期时间后格式成"/Date(1333245600000+0800)/" 转换成正常格式
    技术胖-胜洪宇关注web前端技术
    百度editor编辑器添加新字体
    mvc4中的 webapi 的使用方式
    js特效不错的网站
  • 原文地址:https://www.cnblogs.com/sggggr/p/9214278.html
Copyright © 2011-2022 走看看