PDA

View Full Version : Getting QWidget::windowIcon to work



graeme
1st April 2006, 22:06
Hi,

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)
{
detach();
Q_ASSERT(i >= 0 && i < height());
return d->data + i * d->bytes_per_line;
}


Any help would be gratefully received.

graeme.

jacek
1st April 2006, 22:13
http://www.trolltech.com/developer/tasktracker.html?method=entry&id=95955
http://www.trolltech.com/developer/tasktracker.html?method=entry&id=100119

graeme
1st April 2006, 22:20
Thanks,

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.

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

graeme
1st April 2006, 23: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.

graeme.

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

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

jacek
2nd April 2006, 15: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.