PDA

View Full Version : App cannot load resource images - why?



MarkoSan
13th September 2015, 10:45
I am working on QML app and here is project structure:
11370
As you can see, in I have resource file ueicons.qrc, which contains icons, used in app. I tried to add icons with:


import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
import QtQuick.Dialogs 1.2
import QtMultimedia 5.0
import QtQuick.Layouts 1.0
import QtTest 1.1

import "gui/windows"
import "gui/items"

ApplicationWindow
{
id: ueWindowMain

title: qsTr("testapp")

width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableWidth

visible: true

opacity: 1.0

contentOrientation: Qt.LandscapeOrientation

color: "black"

UeKeypad
{
id: ueLoginKeypad
} // ueLoginKeypad

StatusBar
{
id: ueStatusBar

RowLayout
{
spacing: 8

UeStatusIndicator
{
id: ueStatusIndicatorDatabaseConnected

ueParamImageStatusOn: "qrc:///ueIcons/ueDbConnectionOk.png"
ueParamImageStatusOff: "qrc:///ueIcons/ueDbConnectionError.png"
} // ueStatusIndicatorDatabaseConnected
} // RowLayout
} // ueStatusBar
} // ueWindowMain

And when I run this app, I get following QML error:


QML Image: Cannot open: qrc:///ueIcons/ueDbConnectionError.png

Why?

anda_skoa
13th September 2015, 12:15
If you have C++ code, you could create a QDir on ":/ueIcons", check if it exists, is a directory and entryList() returns the values.

Or use a GammaRay (http://www.kdab.com/gammaray/) to do runtime inspection of the actual application.

Cheers,
_

ChrisW67
13th September 2015, 21:24
AFAICT, the path to the icon is:


qrc:///ueIcons/icons/ueDbConnectionOk.png