Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
bigb2009
Posts: 34
Registered: ‎11-25-2009
My Device: Not Specified
Accepted Solution

QPixmap issue, wondering if I am doing something wrong here..

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,

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QPixmap issue, wondering if I am doing something wrong here..

It's unclear if the "complaining when loading" part is the same as the "message that it's a null pixmap".

Are you getting two errors/warnings here, or just one? And what's the actual message (from the log file, presumably)?

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Developer
bigb2009
Posts: 34
Registered: ‎11-25-2009
My Device: Not Specified

Re: QPixmap issue, wondering if I am doing something wrong here..

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. 

Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QPixmap issue, wondering if I am doing something wrong here..

Path issues are relatively easy to solve, at least once you know a few basics.

The app's current directory is always the folder above the "app/" symlink. The app/ symlink points to the read-only folder where the .bar file contents are unpacked directly (no rearranging of the contents takes place).

Therefore you can generally just verify that the argument to pixmap1() would be rooted at the current directory, check the layout of the contents of your .bar file (on many systems "unzip -t mybar.bar" will show you that), and then usually the issue is clear.

When it's not clear, it's generally because a routine like pixmap1() is looking in some place defined by a Qt setting or environment variable, but then you just need to verify what those are set to.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
jheron
Posts: 188
Registered: ‎01-27-2012
My Device: playbook

Re: QPixmap issue, wondering if I am doing something wrong here..

[ Edited ]

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

New Developer
bigb2009
Posts: 34
Registered: ‎11-25-2009
My Device: Not Specified

Re: QPixmap issue, wondering if I am doing something wrong here..

Thank you Peter and Jon, going to play around with it more tomorrow. I just wanted to make sure I wasn't doing anything really stupid. Haha....

Is there any specific place I can chip in on the qt porting/testing/documentation? I have various machines at my disposal, and quite a few resources.

I have mainly been doing ports from Solaris to linux(my job), and consider this a hobby. I'd love to help out.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10

Re: QPixmap issue, wondering if I am doing something wrong here..

You could pop into the #qt-qnx IRC channel on Freenode and ask some of the guys there, since some of the core folks involved seem to hang out there these days. If nothing else it's more timely status info...

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Developer
bigb2009
Posts: 34
Registered: ‎11-25-2009
My Device: Not Specified

Re: QPixmap issue, wondering if I am doing something wrong here..

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,

Developer
jheron
Posts: 188
Registered: ‎01-27-2012
My Device: playbook

Re: QPixmap issue, wondering if I am doing something wrong here..

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

 

Developer
jheron
Posts: 188
Registered: ‎01-27-2012
My Device: playbook

Re: QPixmap issue, wondering if I am doing something wrong here..

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