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. Display icon into QLabel [SOLVED]
QtWS25 Last Chance

Display icon into QLabel [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
c++linuxiconqlabel
4 Posts 2 Posters 29.3k Views
  • 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.
  • M Offline
    M Offline
    marlenet15
    wrote on 25 Sept 2015, 17:23 last edited by marlenet15
    #1

    I would like to use @standardIcon(QStyle::SP_DialogOkButton)@ for a QLabel. However, QLabel does not have setIcon like QPushButton. Is it possible to set it as a Pixmap? Also, I would prefer not to download any image and just get it from QStyle. Thank you.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 25 Sept 2015, 20:36 last edited by
      #2

      Hi,

      You can use QIcon::pixmap to get one for your QLabel.

      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
      • M Offline
        M Offline
        marlenet15
        wrote on 25 Sept 2015, 20:58 last edited by
        #3

        I am not sure how to write it.
        label->setPixmap(QIcon::())
        I am not sure what do after that. Please help me.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 25 Sept 2015, 21:03 last edited by
          #4

          Something like:

          QIcon icon = style()->standardIcon(QStyle::SP_DialogOkButton);
          QPixmap pixmap = icon.pixmap(QSize(64, 64));
          

          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
          4

          3/4

          25 Sept 2015, 20:58

          • Login

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