Results 1 to 8 of 8

Thread: Getting QWidget::windowIcon to work

  1. #1
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Getting QWidget::windowIcon to work

    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:

    Qt Code:
    1. uchar *QImage::scanLine(int i)
    2. {
    3. detach();
    4. Q_ASSERT(i >= 0 && i < height());
    5. return d->data + i * d->bytes_per_line;
    6. }
    To copy to clipboard, switch view to plain text mode 

    Any help would be gratefully received.

    graeme.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

  3. #3
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting QWidget::windowIcon to work

    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.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting QWidget::windowIcon to work

    Open the .ui file in a text editor and check what path is there. The safest way is to store icons as resources.

  5. The following user says thank you to jacek for this useful post:

    graeme (1st April 2006)

  6. #5
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting QWidget::windowIcon to work

    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.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting QWidget::windowIcon to work

    Quote Originally Posted by graeme
    wait for 4.1.1 to fix the problem.
    Actually, Qt 4.1.2 was released two days ago

  8. #7
    Join Date
    Jan 2006
    Posts
    40
    Thanks
    3
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting QWidget::windowIcon to work

    Alas it doesn't appear to be fixed in 4.1.2

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Getting QWidget::windowIcon to work

    Quote Originally Posted by graeme
    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.

Similar Threads

  1. work with web generated xml
    By emental86 in forum Qt Programming
    Replies: 1
    Last Post: 11th February 2009, 13:51
  2. QXmlQuery problems - recipe example doesn't work
    By nhelseth in forum Qt Programming
    Replies: 0
    Last Post: 16th January 2009, 21:45
  3. Qt4 : QPainter::setRedirected doesn't work
    By Ankitha Varsha in forum Qt Programming
    Replies: 2
    Last Post: 20th June 2008, 17:52
  4. QActions don't work with menubar hidden
    By Pepe in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2007, 01:04
  5. Change work area OS
    By pakulo in forum Qt Programming
    Replies: 15
    Last Post: 15th May 2007, 07:20

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.