Qt 如何在QML中加载*.tiff文件

Qt 如何在QML中加载*.tiff文件,qt,qml,Qt,Qml,根据Qt5,它可以读取tiff文件。但我无法将tiff图像加载到QML 我的代码: Rectangle{ id:backazimuth_image anchors.horizontalCenter: parent.horizontalCenter height:geri.height width:geri.width Image { id:geri width: 300 height: 300

根据Qt5,它可以读取tiff文件。但我无法将tiff图像加载到QML

我的代码:

Rectangle{
    id:backazimuth_image
    anchors.horizontalCenter: parent.horizontalCenter
    height:geri.height
    width:geri.width
    Image {
        id:geri
        width: 300
        height: 300
        fillMode: Image.PreserveAspectFit
        source:"../images/geri.tiff" 
    }
}

您的qrc资源文件中似乎没有tif文件。尝试添加
文件

例如:

import QtQuick 2.7
import QtQuick.Controls 2.0

ApplicationWindow {
    id: window
    visible: true
    width: 640
    height: 480
    title: qsTr("")

    Rectangle
    {
        id: myRect
        height: 200
        width: 200

        Image
        {
            width: 100
            height: 100
            fillMode: Image.PreserveAspectFit
            source: "file:///home/user/dir/file.tif"
        }
    }
}

将其添加到qrc文件后,它就可以工作了。非常感谢。