Results 1 to 6 of 6

Thread: Images is not being set on the push button

  1. #1
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Images is not being set on the push button

    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

    Qt Code:
    1. QPixmap pixmap2("/media/mmcblk0p1/Images/rec2_38x38.jpg");
    2. QIcon icon2(pixmap2);
    3. ui->record->setIcon(icon2);
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. #record
    2. {
    3. background-image: url(:/demo/images/rec2_38x38.jpg);
    4. border: 1px solid #820a09;
    5. border-radius: 10px;
    6. }
    7.  
    8. #record:focus
    9. {
    10. border: 5px solid #ef0703;
    11. border-radius: 10px;
    12. }
    To copy to clipboard, switch view to plain text mode 

    But no image in this case also.

    Don't know where's the problem.
    Last edited by Charvi; 6th July 2012 at 11:05.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Images is not being set on the push button

    Does your code even compile? Line #3 of the first snippet is incorrect.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Images is not being set on the push button

    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

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Images is not being set on the push button

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Images is not being set on the push button

    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.
    Last edited by Charvi; 6th July 2012 at 12:44.

  6. #6
    Join Date
    Mar 2012
    Location
    India
    Posts
    102
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Images is not being set on the push button

    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.
    Last edited by Charvi; 7th July 2012 at 09:28.

Similar Threads

  1. Action using Push Button ?
    By steve.bush in forum Newbie
    Replies: 7
    Last Post: 25th February 2016, 15:36
  2. Need help to design push button
    By keyurparekh in forum Qt Programming
    Replies: 4
    Last Post: 29th March 2011, 13:39
  3. Push Button with image?
    By steve.bush in forum Newbie
    Replies: 10
    Last Post: 18th March 2011, 06:48
  4. [QT]Push button-no action
    By nqn in forum Newbie
    Replies: 4
    Last Post: 30th May 2010, 19:08
  5. Push Button problem!!
    By Seema Rao in forum Qt Programming
    Replies: 1
    Last Post: 22nd April 2006, 16:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.