Results 1 to 4 of 4

Thread: Adding Image to QPushButton

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2011
    Posts
    45
    Qt products
    Qt4
    Platforms
    Symbian S60

    Post Re: Adding Image to QPushButton

    Qt Code:
    1. #include "mainwindow.h"
    2.  
    3. #include <QtGui/QApplication>
    4. #include<QPushButton>
    5. #include<QIcon>
    6.  
    7.  
    8.  
    9.  
    10. int main(int argc, char *argv[])
    11. {
    12. QApplication app(argc, argv);
    13.  
    14. QPushButton *button = new QPushButton ();
    15.  
    16. button->setIcon(QIcon("favicon.Icon"));
    17.  
    18. button->show();
    19.  
    20.  
    21.  
    22. return app.exec();
    23. }
    To copy to clipboard, switch view to plain text mode 

    Hi all i am new to qt and i am trying to add images to Qpushbutton but i was not to get the image displayed in the button?I dont know where i go wrong can anyone help me with this ?
    Here is the code which i have tried.


    Regards,
    Harish
    Last edited by Lykurg; 18th November 2011 at 09:06. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: Adding Image to QPushButton

    Do you have the image plugin that handles icon files? Try a png and you hopefully see, that it works.

Similar Threads

  1. QPushButton with image - text alignment
    By vladeck in forum Newbie
    Replies: 3
    Last Post: 1st July 2009, 19:20
  2. QPushButton with image on it
    By msmihai in forum Newbie
    Replies: 1
    Last Post: 6th January 2009, 20:53
  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, 15:36
  4. Finding marks on scanned image for alignment
    By caduel in forum Qt Programming
    Replies: 1
    Last Post: 23rd September 2007, 02:10
  5. BG image on QPushButton using style sheets??
    By JimDaniel in forum Newbie
    Replies: 2
    Last Post: 13th September 2007, 03: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.