zoukankan      html  css  js  c++  java
  • Qt Quick——新建一个QML

    1、建一个Qt Quick Application程序,然后修改main.qml文件

      修改Windows中的内容,修改如下:

     1 import QtQuick 2.6//导入组件:类库、JS文件、QML文件
     2 import QtQuick.Window 2.2
     3 
     4 Window {//在VS中 没有Window,有Rectangle。所以不要修改根元素的名字
     5     visible: true
     6     /*声明属性:
     7         <属性名称>:<属性值>
     8     */
     9     x:0;y:0
    10      360
    11     height: 480
    12     title: qsTr("Hello World")
    13 
    14     Image{
    15         source:"file:///F:/Workspace/Qt/QtQuick/image/sunny.png"
    16        // source:"../image/sunny.png"
    17     }
    18     MouseArea{
    19         anchors.fill: parent
    20         onClicked: {// 鼠标点击事件
    21             Qt.quit()
    22         }
    23     }
    24     Text{
    25         id:text
    26         y:image.height +20
    27         property int age: 12
    28         /*自定义变量
    29             property type name: value
    30             property 类型 变量名:变量值
    31         */
    32         text:"This is Qt Quick   "+12
    33     }
    34 }

    在Image子元素中
      在VS+Qt中:使用相对路径,可以加载jpg图片不能加载png图片
      在Qt Creator中:使用 绝对路径file可以加载png、jpg图片
      资源文件没有试。

  • 相关阅读:
    11.2~11.8 每周总结
    11.30~11.6 每周总结
    架构之美 图书笔记 03
    每周总结 10.26-11.1
    每周总结 10.19-10.25
    每周总结 10.12-10.18
    [Tips] centos下docker服务开机自启动
    [Notes] Linux内网穿透
    [Tips] python 文件读写
    [Tips] python 文件读写
  • 原文地址:https://www.cnblogs.com/wangbin-heng/p/9557395.html
Copyright © 2011-2022 走看看