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;
    }

     

    
    
    
  • 相关阅读:
    HDU 1249 三角形
    HDU 1799 循环多少次?
    UVA 12219-Common Subexpression Elimination
    POJ 2253-Frogger(最小生成树的最大权)
    OpenCV之参数不匹配问题
    vs2017-关于配置属性管理器的问题
    D
    圆桌会议
    F
    B
  • 原文地址:https://www.cnblogs.com/sggggr/p/9214278.html
Copyright © 2011-2022 走看看