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

     

    
    
    
  • 相关阅读:
    添加Google Admob到ANDROID应用中
    linux命令及实例说明一:cd、ls、rmdir、rm、mkdir
    android中dip、dp、px、sp和屏幕密度
    在程序中读取ANDROID应用的程序名称和版本号
    linux常用命令及实例二:cp、mv、chown、chmod、find
    Android开发,常用的终端命令
    eclipse里配置solr开发测试环境
    自定义Dialog之Progress(二)
    android 判断网络状态
    hive cli命令行选项
  • 原文地址:https://www.cnblogs.com/sggggr/p/9214278.html
Copyright © 2011-2022 走看看