[Solved] SetIcon not working for a QPushButton
-
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? -
buttonicon is not a const QIcon?
-
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.
-
Line 2 :
@
QPixmap pixmap(":/MonitorWindowPix/Manual Icon.png");
@
Should be
@
QPixmap pixmap(":/MonitorWindowPix/Manual/Icon.png");
@
With the / -
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? -
[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? -
Ok my mistake.
I tend to avoid spaces in filenames. A long time ago i worked on DOS ;)