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. QPixmap from theme to label
Forum Updated to NodeBB v4.3 + New Features

QPixmap from theme to label

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.8k Views 1 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.
  • A Offline
    A Offline
    alexandros
    wrote on last edited by
    #1

    I want to set a qpixmap (fromtheme) to a label, but I cannot find the way. I only know how to set it to a button using the button's properties.

    Any clue?

    Thanks in advance!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vezprog
      wrote on last edited by
      #2

      Defined a QLabel...then set the Pixmap. You can auto scale content as well if you want the image to fit the border. You can do this easily with the interface builder in the properties panel.

      @
      QLabel templabel;
      templabel.setPixmap("my_image.png");
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alexandros
        wrote on last edited by
        #3

        Tanks for this, but what I actually need is to use the QIcon::fromtheme() function so as to read the theme's icons!

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          Well, a QIcon is not a QPixmap. Did you read the [[doc:QIcon]] documentation to see if you might be able to get a (or perhaps more...) pixmap from a QIcon somehow?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            alexandros
            wrote on last edited by
            #5

            Yep, I found a solution:
            @QPixmap pix=QIcon::fromTheme("dialog-error").pixmap(22);@

            Yet, thanks for being kind with the newbies :)

            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