[Solved] SetIcon not working for a QPushButton
-
wrote on 21 Oct 2011, 18:51 last edited by
I have the following code snippet for defining a QPushButton and putting it on my window:
@
manAutoButton = new QPushButton(this);
QPixmap pixmap(":/MonitorWindowPix/Manual Icon.png");
QIcon buttonicon(pixmap);
manAutoButton->setIcon(buttonicon);
manAutoButton->move(629, 270);
@
When I try to run it, I get a compilation error saying that QPushButton has no member named SetIcon. Qt documentation verifies that QPushButton has the SetIcon member. What's wrong with this code? -
wrote on 21 Oct 2011, 19:39 last edited by
buttonicon is not a const QIcon?
-
wrote on 21 Oct 2011, 19:52 last edited by
I can make one or both of pixmap and buttonicon const, but I still get the error telling me that SetIcon is not a member of QPushButton.
-
wrote on 21 Oct 2011, 20:38 last edited by
Line 2 :
@
QPixmap pixmap(":/MonitorWindowPix/Manual Icon.png");
@
Should be
@
QPixmap pixmap(":/MonitorWindowPix/Manual/Icon.png");
@
With the / -
wrote on 21 Oct 2011, 21:37 last edited by
You write of SetIcon in you posts, but have setIcon in your code (lower/upper case s/S). Which one do you actually use?
PS:
Of which type is the pointer manAutoButton? -
wrote on 22 Oct 2011, 10:36 last edited by
[quote author="Eddy" date="1319229513"]Line 2 :
@
QPixmap pixmap(":/MonitorWindowPix/Manual Icon.png");
@
Should be
@
QPixmap pixmap(":/MonitorWindowPix/Manual/Icon.png");
@
With the /
[/quote]
Why is that? Since when are spaces in file names not supported anymore? -
wrote on 22 Oct 2011, 12:14 last edited by
Ok my mistake.
I tend to avoid spaces in filenames. A long time ago i worked on DOS ;)
1/7