PDA

View Full Version : Qt 4.8: QLabel not showing SVG, QButton does



oliverg
26th April 2012, 14:47
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).

oliverg
30th April 2012, 08:42
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


QIcon status_icon_good;
QSize status_icon_size_hint;


in source


status_icon_good(":/qkascha/icons/status_good.svg"),
status_icon_size_hint(48, 48)
{
ui->label_main_modus_icon->setPixmap(status_icon_good.pixmap(status_icon_size _hint));


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.