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. Can I set QLabel background image using setProperty()?
Qt 6.11 is out! See what's new in the release blog

Can I set QLabel background image using setProperty()?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.5k 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.
  • ericg22E Offline
    ericg22E Offline
    ericg22
    wrote on last edited by
    #1

    Hello Qt'perts,

    Is there a way to set a QLabel background-image programmatically from a pixmap, eg using QLabel::setProperty(). I realize it can be set from a path using setStylesheet() but in this case I only have access to the actual QPixmap and not the resource path. Any code examples as to how to do this would be much appreciated.

    Regards,

    Eric G
    Peloton Technology

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

      Hi,

      Why not just set an image on the QLabel ?

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

      ericg22E 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Why not just set an image on the QLabel ?

        ericg22E Offline
        ericg22E Offline
        ericg22
        wrote on last edited by
        #3

        @SGaist I cannot set the label's pixamp because it is being used to display text and I want to add the image as background to the text.

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

          Since you can't do it from a style sheet, draw your text on the pixmap before setting it on the label. That would likely be simpler.

          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