[SOLVED]can not declare QIcon in class?
Hi all,
I have a “strange” problem.
I want to declare a QIcon in my header file(class) and set its filename in the constructor.
But when i add “QIcon icon;” in my class, the program crashes when started.
When i add “QIcon icon” in a constructor/function it works as it should be.
Can someone please explain if im doing something wrong here?
10 replies
Just for kicks, change the name to m_icon and see what happens.
Obviously it isn’t just the fact that you do
- QIcon *icon
Hi Franzk,
I’m sorry if i’m not clear here, so i try to explain myself a little better now.
I’m writing a little test program where i want to have a icon shown in a listview.
if i use a function call like:
then everything works like a charme.
If i do :
- item->setIcon(proeficon);
everything works like a charme.
If i do:
- QIcon proeficon;
- proeficon.addFile(":/icon/pic5");
- item->setIcon(proeficon);
everything works like a charme.
But if i do:
In header:
- QIcon proeficon;
And in the constructor:
- proeficon.addFile(":/icon/pic5");
Then my program crashes.
I hope i did explain it better now?
You must log in to post a reply. Not a member yet? Register here!




