PDA

View Full Version : [Solved] Button setIcon do not work



robelle
30th January 2013, 11:10
Hi,
i want add image to my button and do not use text
for that i amke like that


Button=new QToolButton(page_13);
Button->setGeometry(QRect(10, 70, 101, 91));
Button->setIcon(QIcon("E:\image\img.JPG"));

BUT i do not see my image , just umpty button
that's my image
8654

wysota
30th January 2013, 11:49
What does isNull() return for your icon?

robelle
30th January 2013, 12:49
What does isNull() return for your icon?
is there "isnull" in Qtoolbuton to test icon ?

Lesiok
30th January 2013, 12:57
Did You have a plugin for JPG files ?

robelle
30th January 2013, 13:00
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 ?

Lesiok
30th January 2013, 13:06
What You see on screen after this :
foreach(QString imageType, QImageReader::supportedImageFormats())
qDebug() << imageType;

robelle
30th January 2013, 13:37
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

"E:\image\img.JPG"
and it must to be like that

E:/image/img.jpg
:p

Lesiok
30th January 2013, 13:42
This is a C/C++ abc. Should be :
"E:\\image\\img.JPG"