QPixmap from theme to label



  • 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!



  • 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");
    @



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



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



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

    Yet, thanks for being kind with the newbies :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.