QT 无法使用已经加载的资源文件

今天在实验QT 加载图片资源的时候,出现无法加载图片错误。经过在网上找了一通,找到了解决方法,当每次修改了xxx.qrc文件的时候,都需要build -> run qmake 一次

 

QML中的代码如下:

import QtQuick 2.9
import QtQuick.Window 2.2

Window {
    visible: true
    width: 640
    height: 480
    title: qsTr("Hello World")
    MouseArea{
        anchors.fill: parent
        onClicked:
        {
           ///Qt.quit();
        }
    }
    Text {
        id: id_first
        text: qsTr("my text")
        anchors.centerIn: parent
    }
    Rectangle{
        x:parent.width - 50 // 设置矩形框的位置和大小
        y:20
        width: 30
        height: 40
        anchors.right: parent
        color: "lightblue"
        Text {
            id: name
            text: qsTr("点我")
        }
        MouseArea
        {
            anchors.fill: parent
            onPressed: parent.color = "red"
            onReleased: parent.color = "lightblue"
        }
    }
    //添加图片
    BorderImage {
        id: showimage
        source: "./images/1.png"
        width: 100; height: 100
        border.left: 5; border.top: 5
        border.right: 5; border.bottom: 5
    }
    //添加动画gif图片
    Rectangle{
        y: 100
        width: animation.width
        height: animation.height + 8
        AnimatedImage{
            id:animation;
            source: "./Loading.gif"
        }
        Rectangle{
            property int frame : animation.frameCount
            width: 4
            height: 8
            x:(animation.width - width) * animation.currentFrame / frame
            y: animation.height
            color: "red"
        }
    }
    /**/
}

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值