Results 1 to 6 of 6

Thread: Images is not being set on the push button

Threaded View

Previous Post Previous Post   Next Post Next Post
  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.

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
  •  
Qt is a trademark of The Qt Company.