PDA

View Full Version : Images is not being set on the push button



Charvi
6th July 2012, 07:58
Hi,

I am trying to set an image as the background of a push button with the help of following code but the image doesn't appear on the button :(



QPixmap pixmap2("/media/mmcblk0p1/Images/rec2_38x38.jpg");
QIcon icon2(pixmap2);
ui->record->setIcon(icon2);


I checked the path of the image its correct.

I also tried putting the image to the resources file and setting it through the Style Sheet as follows:



#record
{
background-image: url(:/demo/images/rec2_38x38.jpg);
border: 1px solid #820a09;
border-radius: 10px;
}

#record:focus
{
border: 5px solid #ef0703;
border-radius: 10px;
}


But no image in this case also. :(

Don't know where's the problem.

wysota
6th July 2012, 10:19
Does your code even compile? Line #3 of the first snippet is incorrect.

Charvi
6th July 2012, 12:08
Even the labels are not getting the background images on my embedded device. This means i cannot set images on anything.
Made apps for the same device previously also didn't get any such problem then.

I am running the app with "-display transformed:Rot270" is this the culprit ??

Edit: No even without this I am not getting the images. :(

Edit: I have cross-compiled the Qt library with this configure statement:

./configure -embedded arm -xplatform qws/linux-arm-g++ -prefix /opt/Qt_rot/Qt4.8.3 -little-endian -no-largefile -no-qt3support -no-svg -qt-libpng -qt-libtiff -qt-libjpeg -no-cups -qt-gfx-transformed -optimized-qmake

wysota
6th July 2012, 12:25
Could you please answer my question? The code you posted will not compile, is that your actual code? Make sure you are not running some old binary that didn't include this error.

Charvi
6th July 2012, 12:43
Ohh sorry for not answering. but that was some mistake. I edited my post to remove it and ya my code compiles.

Now I have dug deeper and found that the prob is with the jpeg format images, png works fine. I think I have to use the libjpeg.so from the plugins/imageformats/ folder in my installation. I tried and put that in /usr/lib/. of my device along with the other Qt libraries. Still no jpeg image showing up.

Where do I have to put this ?
I think this will solve it.

Edit:: ok i think i also need to add some plugin inclusion lines of code in my program. But how? I have compiled it dynamically.

Charvi
7th July 2012, 10:28
I tried adding qApp.addLibrarypaths to give the path of my libqjpeg.so but still no help.
What more am I missing?

Added after 1 14 minutes:

Got it working.
I had to create an imageformats directory in my directory where the binary is located. In this directory I had to put the libqjpeg.so. That's it !!
Make no change inside the application.

Thanks everybody.