Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[Solved] Using nested resources in C++/QML files
From my main C++ code (see below), I'm calling an animation QML file that's in my resources. This is what my main function looks like:
int main(int argc, char *argv)
QApplication app(argc, argv);
Inside the animation.qml file, it's using an image that's also a resource file. Here's an abbreviated version of the QML file:
width: 1430; height: 800; color: "lightsteelblue"
(a NumberAnimation and a ParallelAnimation)
The lightsteelblue window for the animation comes up fine, so I know the C++ part is doing its job, but I never see the image or the animation in the window that appears. I know the QML file works fine because when I execute it alone, everything moves as it should. Is there some special trick to calling a resource file from a resource file?
Diph last edited by
Just use relative path specified in the qrc:
I switched the source in the QML to "/MyFiles/krlogo.jpg" and had no luck. But I then changed it to "/MyFiles/KRLogo.jpg", and it worked. Since when are filespecs case-sensitive?
Also, why is the title of my post in gray whereas most are in black? Am I on some kind of naughty list? :o)
Diph last edited by
I guess unread threads are in black. :)
Qt resources are always case-sensitive (as are the filesystems on unix/OSX). Windows' file system is the odd man out, being case-insensitive. In practice, it's generally a good rule to assume that filenames are case-sensitive.
Thanks for the posts. I've only ever worked in a Windows environment. Very interesting about the others platforms. I'll certainly start paying attention to that!
Good deal! Glad it helped.
goetz last edited by
[quote author="mlong" date="1314385199"]Qt resources are always case-sensitive (as are the filesystems on unix/OSX). Windows' file system is the odd man out, being case-insensitive. In practice, it's generally a good rule to assume that filenames are case-sensitive.
Just for the records
Mac OS X HFS+ with standard settings is case insensitive too.
One should always use the right case, though. That saves you from trouble later, when you're on case sensitive systems.