Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Example sought: overlapping images
Servers for Qt installer are currently down

Example sought: overlapping images

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 1 Posters 914 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.
  • C Offline
    C Offline
    Captain Haddock
    wrote on 19 Apr 2023, 12:26 last edited by
    #1

    I am seeking example code for how to overlap two pixmaps (QLabel) widgets (so that I can build a graphic from several component images).

    Any help/pointers would be welcome.

    Thanks, Haddock

    C 1 Reply Last reply 19 Apr 2023, 13:41
    0
    • J jsulm referenced this topic on 19 Apr 2023, 13:02
    • C Captain Haddock
      19 Apr 2023, 12:26

      I am seeking example code for how to overlap two pixmaps (QLabel) widgets (so that I can build a graphic from several component images).

      Any help/pointers would be welcome.

      Thanks, Haddock

      C Offline
      C Offline
      Captain Haddock
      wrote on 19 Apr 2023, 13:41 last edited by
      #2

      To be more explicit I am trying to build a composite image like this: alt text

      .. but by building from an image that is of one layer of the stack. The goal is to be able to build the stack to a given number of layers.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Captain Haddock
        wrote on 19 Apr 2023, 16:42 last edited by Captain Haddock
        #3

        RESOLVED: In order to compose the desired stack image I needed to use a QPainter. My logic was roughly:

        baseImage = QtGui.QImage("<path to base image>")
        
        stackSize = 3
        stackImageSize = QtCore.QSize(baseImage.width(), baseImage.height() * stackSize)
        stack = QtGui.QImage(size, QtGui.QImage.Format.Format_ARGB32)
        stack.fill(QtGui.QColor(0, 0, 0, 0))
        
        painter = QtGui.QPainter()
        painter.begin(stack)
                for i in range(count):
                    adjust = baseImageHeight * i + baseImageHeight - 6 * i
                    painter.drawImage(0, size.height() - adjust, unselected)
        painter.end()
        
        label = QtWidgets.QLabel()
        label.setFixedHeight(size.height())
        label.setFixedWidth(size.width())
        
        label.setPixmap(QtGui.QPixmap.fromImage(stack))
        
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(label)
        self.setLayout(layout)
        
        1 Reply Last reply
        1
        • C Captain Haddock has marked this topic as solved on 19 Apr 2023, 17:22

        1/3

        19 Apr 2023, 12:26

        • Login

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