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. Fit a large image as a background to QWidget
Qt 6.11 is out! See what's new in the release blog

Fit a large image as a background to QWidget

Scheduled Pinned Locked Moved General and Desktop
3 Posts 3 Posters 1.6k 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
    Arus1
    wrote on last edited by
    #1

    An image should be shown twice smaller on QWidget but it should not cover the whole widget.
    Is it possible to change size of the image when setting stylesheet or set QIcon/QPixmap to QWidget?
    Thanks.

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

      Use border properties in style sheet to leave some border or override paintEvent in Qwidget to draw the scaled pixmaps.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        thEClaw
        wrote on last edited by
        #3

        Either use a stylesheet on the widget (you have a couple of options for background images) or overwrite the widgets "paintEvent()":http://qt-project.org/doc/qt-5/qwidget.html#paintEvent . In there you have full control over how the widget is drawn to the screen - but you have to be careful to not waste too many resources.

        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