Results 1 to 8 of 8

Thread: [Solved] Button setIcon do not work

  1. #1
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default [Solved] Button setIcon do not work

    Hi,
    i want add image to my button and do not use text
    for that i amke like that
    Qt Code:
    1. Button=new QToolButton(page_13);
    2. Button->setGeometry(QRect(10, 70, 101, 91));
    3. Button->setIcon(QIcon("E:\image\img.JPG"));
    To copy to clipboard, switch view to plain text mode 
    BUT i do not see my image , just umpty button
    that's my image
    img.jpg
    Last edited by robelle; 30th January 2013 at 15:24.

  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: Button setIcon do not work

    What does isNull() return for your icon?
    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
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Button setIcon do not work

    What does isNull() return for your icon?
    is there "isnull" in Qtoolbuton to test icon ?

  4. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Button setIcon do not work

    Did You have a plugin for JPG files ?

  5. #5
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Button setIcon do not work

    No,
    i just add the code in my first reply, i did not add any line to read the image ? does i must read iyt before ?

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Button setIcon do not work

    What You see on screen after this :
    Qt Code:
    1. foreach(QString imageType, QImageReader::supportedImageFormats())
    2. qDebug() << imageType;
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Sep 2012
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Button setIcon do not work

    i see the "jpg",bmp"...................................


    Added after 10 minutes:


    it work
    the problem was in the linf of the image
    i make it like that
    Qt Code:
    1. "E:\image\img.JPG"
    To copy to clipboard, switch view to plain text mode 
    and it must to be like that
    Qt Code:
    1. E:/image/img.jpg
    To copy to clipboard, switch view to plain text mode 
    Last edited by robelle; 30th January 2013 at 13:37.

  8. #8
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Button setIcon do not work

    This is a C/C++ abc. Should be :
    Qt Code:
    1. "E:\\image\\img.JPG"
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Adding button to QMessageBox doesn't work
    By code_err in forum Newbie
    Replies: 4
    Last Post: 8th February 2012, 21:40
  2. SetIcon ON for pushbutton does not work
    By tonnot in forum Newbie
    Replies: 6
    Last Post: 14th September 2011, 12:24
  3. Maximize button doesn't work
    By Morgan Cormier in forum Qt Programming
    Replies: 6
    Last Post: 24th March 2011, 19:33
  4. QDoubleValidator, top and button range does not work..
    By webquinty in forum Qt for Embedded and Mobile
    Replies: 5
    Last Post: 26th August 2009, 09:17
  5. why doesn't the button work?
    By mattia in forum Newbie
    Replies: 18
    Last Post: 5th November 2007, 12:14

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.