Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. XPM Icons Work in Designer but not in App
Forum Updated to NodeBB v4.3 + New Features

XPM Icons Work in Designer but not in App

Scheduled Pinned Locked Moved General and Desktop
httpsforum.qt.i
6 Posts 3 Posters 1.7k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DougyDrumz
    wrote on last edited by
    #1

    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.

    Dougy Drumz

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      How are you trying to load your XPM images ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      D 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        How are you trying to load your XPM images ?

        D Offline
        D Offline
        DougyDrumz
        wrote on last edited by
        #3

        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());  
        

        Dougy Drumz

        yeckelY 1 Reply Last reply
        0
        • D DougyDrumz

          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());  
          
          yeckelY Offline
          yeckelY Offline
          yeckel
          wrote on last edited by
          #4

          @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?

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DougyDrumz
            wrote on last edited by
            #5

            It is 4.6.2.

            Dougy Drumz

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              And does it work when you give to full path to the file ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved