XPM Icons Work in Designer but not in App
-
I have some old XPMs I would like to use as icons. When I set the pixmap to an XPM for a QLabel in designer, it works fine. When I build my App (using cmake), and run, the icons don't show up. I don't have this problem with PNGs. Any ideas? As a workaround, I used GIMP to create snapshots of these XPMs and saved them as PNGs. However, I work like to know how to get XPMs work in an App.
-
Hi and welcome to devnet,
How are you trying to load your XPM images ?
-
Using the generated code (ui_MyGUI.h):
… QLabel *myXpmLabel; … myXpmLabel = new QLabel(myTab); myXpmLabel->setObjectName(QString::fromUtf8(“myXpmLabel”)); myXpmLabel->setPixmap(QPixmap(QString::fromUtf8(“icons/diamond.xpm”))); gridLayout_3->addWidget(myXpmLabel, 12, 5, 1, 1); … myXpmLabel->setText(QString());
-
@DougyDrumz Hi this code is working for me, so your should work too:
void MainWindow::on_toolButton_clicked()
{
QLabel *myLabel = new QLabel();
myLabel->setPixmap(QPixmap(QString::fromUtf8("/home/libor/qt5/qtactiveqt/examples/activeqt/menus/fileopen.xpm")));
ui->gridLayout->addWidget(myLabel);
}What's your Qt version?
-
It is 4.6.2.
-
And does it work when you give to full path to the file ?