View Full Version : Getting QWidget::windowIcon to work

1st April 2006, 21:06

I'm not certain if this should be a design or a programming question however...

I want to add an icon to the window of my application. I have used the designer (4.1.0) and added a .png as my icon the image was a 16x16 (although I have tried 24x24 & 32x32 with the same sad result) The designer accepts the image and displays how it will look in the window.

I save, compile and run. But when I run it I get the following problem:

ASSERT: "i>=0 && i< height()" in file image/qimage.cpp, line1311

The code in qimage is as follows:

uchar *QImage::scanLine(int i)
Q_ASSERT(i >= 0 && i < height());
return d->data + i * d->bytes_per_line;

Any help would be gratefully received.


1st April 2006, 21:13

1st April 2006, 21:20

But if that is the problem then it indicates that the designer is using a different path. But which one?

I just tried by putting the file in the same folder as the window no joy, and the same folder as the binary again no joy.

1st April 2006, 21:27
Open the .ui file in a text editor and check what path is there. The safest way is to store icons as resources.

1st April 2006, 22:06
Okay thanks,

I've managed to get it working. For anyone else facing this problem, the ui is created with just the file name, the path is lost, and so it looks for the file from the folder from where you execute the command. This means if you are in the directory where the binary is then the image must be in that directory, however if the command is issued from another directory such as ./../bin/myProg (which was being done for me by my set up in Kdevelop) then the icon needs to be in the pwd (for me the root of my source directory).

The long and the short of it, wait for 4.1.1 to fix the problem.

Once again thank you jacek for providing me with the necessary pointers.


1st April 2006, 22:40
wait for 4.1.1 to fix the problem.
Actually, Qt 4.1.2 was released two days ago ;)

2nd April 2006, 04:21
Alas it doesn't appear to be fixed in 4.1.2 :(

2nd April 2006, 14:02
Alas it doesn't appear to be fixed in 4.1.2 :(
It's strange, both entries in the task tracker seem to describe the same bug, but one is marked as fixed in 4.1.1, while second --- in 4.1.3. You can always try the latest snapshot.