Results 1 to 2 of 2

Thread: QPushButton with image on it

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2008
    Posts
    17
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QPushButton with image on it

    I tried to do a simple thing .Using the QT Designer, i put an image ( png format ) on a QPushButton . When i test the form in the Qt Designer , it shows that picture just fine.
    But when i write an application using that design ( the ui file ) , the buttons doesn't have the picture on it .

    I checked the ui_gui.h file generated by qt and i found this code

    Qt Code:
    1. QIcon icon;
    2. icon.addPixmap(QPixmap(QString::fromUtf8("Button-Reload-48x48.png")), QIcon::Normal, QIcon::Off);
    3. Button1->setIcon(icon);
    To copy to clipboard, switch view to plain text mode 

    So ... it shoud have been there... any ideas ? the picture is 48x48.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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: QPushButton with image on it

    You are using a relative file path and then later when you run the application outside the original directory, the file is not there. Either use an absolute path or embed the image as a Qt resource into the application binary.

Similar Threads

  1. Adding Image to QPushButton
    By Seema Rao in forum Qt Programming
    Replies: 3
    Last Post: 18th November 2011, 10:06
  2. QPushButton with image - text alignment
    By vladeck in forum Newbie
    Replies: 3
    Last Post: 1st July 2009, 20:20
  3. can Qlabel display a series of image one by one ?
    By jirach_gag in forum Qt Tools
    Replies: 3
    Last Post: 11th August 2008, 16:36
  4. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 03:10
  5. BG image on QPushButton using style sheets??
    By JimDaniel in forum Newbie
    Replies: 2
    Last Post: 13th September 2007, 04: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.