<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QWidgets Pixmap not appearing]]></title><description><![CDATA[<p dir="auto">I'm trying to add an image viewer to my Python Qt by creating a Pixmap widget but my current code doesn't seem to do anything. Here is the relevant portion of the code:</p>
<pre><code>from PySide6 import QtCore, QtWidgets, QtGui
from PySide6.QtUiTools import QUiLoader
from PySide6.QtCore import QFile
from ui.ui_mainWindow import Ui_MainWindow
import classes
from PIL import Image, ImageQt

renderedImages = []
allImages = []

class mainWindow(QtWidgets.QMainWindow):
    def __init__(self):
        super(mainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

def openFile():
    global allImages
    getFile = QtWidgets.QFileDialog()
    openedFile, t = getFile.getOpenFileNames(None, "Open Image", "~", "Image Files (*.png *.jpg *.jpeg *.gif *.webp);;Project Files (*.ifx)")
    # Get file to open
    if openedFile.count(".ifx") == 0 and openedFile:
        for i in range(len(openedFile)):
            allImages.append(openedFile[i])
            # Pass new images to be rendered
        # Add opened files to recent file cache
        renderImage(allImages[0])

def renderImage(imageR):
    global drawn
    drawn = QtWidgets.QLabel(window)
    im = Image.open(imageR)
    qIm = ImageQt.ImageQt(im)
    pixmap = QtGui.QPixmap.fromImage(qIm)
    drawn.setPixmap(pixmap)
    drawn.resize(pixmap.width(), pixmap.height())
    global renderedImages
    renderedImages.append(imageR)

if __name__ == "__main__":
    app = QtWidgets.QApplication(sys.argv)
    window = mainWindow()
    refreshWindow()
    window.show()
    # Load main window

    window.ui.actionOpen.triggered.connect(openFile)
</code></pre>
<p dir="auto">I have checked to make sure that it does correctly fetch the path of the opened images and pass it to the render function and this is the case, the code in its current form also does not throw any errors.</p>
]]></description><link>https://forum.qt.io/topic/165022/qwidgets-pixmap-not-appearing</link><generator>RSS for Node</generator><lastBuildDate>Sun, 27 Sep 2026 09:07:04 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/165022.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 19 Aug 2026 13:37:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QWidgets Pixmap not appearing on Wed, 19 Aug 2026 18:46:56 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Your <code>drawn</code> widget is never shown.</p>
<p dir="auto">That said, please stop using globals for everything you are doing.<br />
Take the time to learn how to build proper widgets and use signals and slots cleanly.<br />
Take a look at the <a href="https://doc.qt.io/qtforpython-6/examples/example_widgets_imageviewer.html" target="_blank" rel="noopener noreferrer nofollow ugc">image viewer example</a> for a start.</p>
<p dir="auto">There are many others.</p>
]]></description><link>https://forum.qt.io/post/839789</link><guid isPermaLink="true">https://forum.qt.io/post/839789</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 19 Aug 2026 18:46:56 GMT</pubDate></item></channel></rss>