03-12-2012 03:43 PM
So I am basically doing this :
QPixmap pixmap1("app/native/shadow.png");
And the image is deployed, so I'm a little confused as to why it's complaining when loading this. When trying to display it, I get a message that it's a null pixmap. Something else I need to be doing to get this to show?
Thank you,
Solved! Go to Solution.
03-12-2012 05:03 PM
03-12-2012 06:00 PM
This is exactly what I am doing, in an attempt to fill the Qt background screen with an image.
QPalette p = palette();
QPixmap pixmap1("app/native/shadow.png");
QDesktopWidget* desktopWidget = QApplication::desktop();
QRect rect = desktopWidget->availableGeometry();
QSize size(rect.width() , rect.height());
QPixmap pixmap(pixmap1.scaled(size));
p.setBrush(QPalette::Background, pixmap);
setPalette(p);
And when that runs, the output on the device in the log is about the null pixmap. I'm going from command line, so I don't have the inline debugger, but I guess I could switch things around to the sim, and try to launch this in momentics, but I think it might just be a path thing, but from all the reading I am seeing, I am calling the path correctly.
03-12-2012 06:04 PM
03-12-2012 08:48 PM - edited 03-12-2012 08:51 PM
The Qt resource system is great for fast image and file loading.
In my Qt widget apps I have all my images in the resource file and I access them as follows, works for all platforms without having to worry about paths in different types of packages too:
ui->label_3->setPixmap(QPixmap(QString::fromUtf8(" qrc:/images/image.png")));
Cheers,
Jon
03-12-2012 11:50 PM
03-13-2012 12:08 AM
03-13-2012 04:05 PM
This is the stupidest thing I have ever seen, I can't for the life of me get this to work.. haha.. I'm even using a qrc and still nothing.
Any chance there are any image loading examples floating around someone's system they'd like to send me? I am sure I am doing something dumb(missing a leading slash or something), but without an inline debugger, this could take forever...
Thanks again guys,
03-13-2012 09:40 PM
I've been there bro!
Here is the test app I used to get the qml componets working on the pb. I added an icon to the qml button and I load it from the resource file. Qt makes you add a prefix to the resource file, be sure its in your path.. Also add the line RESOURCES += resFileName.qrc to your pro file and make sure that the resource file is in the same dir as your pro file.
Sorry the app is so big but its all I had handy...
http://www.mediafire.com/?xhbkh3vx3z2emjt
Good luck!
Jon
03-13-2012 09:44 PM
Forgot to mention the test app has the main.qml file set to load for the qt simulator, check the main.cpp to run it on your pb...
Cheers,
Jon