Results 1 to 2 of 2

Thread: Qt 4.8: QLabel not showing SVG, QButton does

  1. #1
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Qt 4.8: QLabel not showing SVG, QButton does

    Hi everyone,
    I have a strange problem when deploying my application. On the development machine everything works fine. When testing on different computers (Windows 7 and Windows XP) it does not. I have some buttons showing SVGs that are included in my resource file. The same is true for some labels. To support SVGs I added the plugins folder to the app folder. This makes the SVGs show up on the buttons as expected. However, it does not work for the labels. I assume it has to do with the fact that QButton uses QIcon while QLabel uses QPixmap. However, I cannot see why this would cause troubles since it does work on my development machine.

    I added the files to the resource file and then applied the icon or pixmap in Designer. So it cannot be a coding issue. Am I missing some files that are needed to convert SVG to pixmap? I added all release DLLs in plugins\iconengines and plugins\imageformats to application folder (preserving the folder structure, of course).

  2. #2
    Join Date
    Jun 2011
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt 4.8: QLabel not showing SVG, QButton does

    I still do not know what is causing the problem. However, I was able to circumvent the problem: Instead of setting the pixmap in designer, I loaded each SVG as a QIcon file and manually assigned this icons pixmap to the label. This is the code:

    In header
    Qt Code:
    1. QIcon status_icon_good;
    2. QSize status_icon_size_hint;
    To copy to clipboard, switch view to plain text mode 

    in source
    Qt Code:
    1. status_icon_good(":/qkascha/icons/status_good.svg"),
    2. status_icon_size_hint(48, 48)
    3. {
    4. ui->label_main_modus_icon->setPixmap(status_icon_good.pixmap(status_icon_size_hint));
    To copy to clipboard, switch view to plain text mode 

    Since I am changing the icons anyhow, this is not much of the problem. Besides that, the code is really simple. However, it is circumventing the problem, not solving it. But it has to do it for now.

Similar Threads

  1. Please Help with QButton
    By agup006 in forum Newbie
    Replies: 1
    Last Post: 19th November 2011, 14:02
  2. Replies: 3
    Last Post: 19th October 2011, 13:41
  3. Replies: 0
    Last Post: 16th December 2010, 16:04
  4. QLabel not showing
    By MarkoSan in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2008, 22:58
  5. ampersand showing in QLabel
    By dave in forum Newbie
    Replies: 6
    Last Post: 7th November 2006, 07:15

Tags for this Thread

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.