You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Friday, October 19th 2012, 10:00am

Image loading failure on Windows7

I have an application with the following code, which creates the button well but no image is displayed on it:

Source code

1
QPushButton* button = new QPushButton(QPixmap("G:\\...\\.....\\test.ico"), "text");


I tried this code to see whether pixmap data member is null, and it is!

Source code

1
2
3
4
5
	QLabel topLevelLabel;
	QPixmap pixmap("G:\\...\\..\\test.ico");
	topLevelLabel.setPixmap(pixmap);
	topLevelLabel.setMask(pixmap.mask());
	topLevelLabel.show();


Exactly the same five rows in an empty application behaves as expected and the icon is shown.
What am I missing?
(naturally QFile::exists returns true for the given path)

Thanks,
Attila

Junior

Professional

  • "Junior" is male

Posts: 1,623

Location: San Antonio, TX USA

Occupation: Senior Secure Systems Engineer

  • Send private message

2

Friday, October 19th 2012, 1:18pm

I didn't see a QPushButton constructor with QPixmap as an argument, there was QIcon( QPixmap ... ) ). What version of Qt are you using?

Oops, miss note: Note that you can also pass a QPixmap object as an icon (thanks to the implicit type conversion provided by C++).

Maybe this is a case where the implicit type conversion is failing - try wrapping it with the QIcon and see if this is the case.

Similar threads

Used tags

image, qicon, QImage, QPixmap