10-12-2012 11:26 AM
Hi,
I have placed an png image in the main folder of my project (same as icon) and I am using..
QIcon *qq = new QIcon("app/native/testimage.png");
but the QIcon is reported as null.
What am I doing wrong please?
10-12-2012 12:32 PM - edited 10-12-2012 12:34 PM
try this QDir::currentPath()
then set your image path relative to that.
some more info:
http://stackoverflow.com/questions/7402576/how-to-
10-12-2012 12:42 PM
You have to add your resources to Assets in bar-descriptor.xml .
Just look to examples of native apps provided by BlackBerry Dev Team
10-12-2012 12:50 PM
Thanks rasm2k,
I have just tried
QIcon *qq = new QIcon(QDir::currentPath()+"/pcicon.png");
item->setData(Qt:
ecorationRole, *qq);
but still I cant see the image in my list and my list delegate reports that it is null after casting in its paint function..
QIcon ic = QIcon(qvariant_cast<QPixmap>(index.data(Qt:
ecorationRole)));
//ic is null after this.
I have watched 3 hours passed by trying to put an image in a list - is qt really this difficult?
10-12-2012 12:51 PM
I have <asset path="pcicon.png">pcicon.png</asset> in my xml file already.
10-12-2012 04:06 PM - edited 10-12-2012 04:13 PM
Consider using the QResource system for all your embedded images and resources. No need to worry about asset paths and such then.
Then you just access with the path like this: "qrc:/prefix/image.png"
Cheers,
Jon
10-12-2012 04:54 PM
Thank you all for your replies,
it turned out it was the way I was casting the image data in the list delegate, I should have cast to QVariant and then to QIcon, still learning!
Regards
C