<?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[QWidget modification at runtime]]></title><description><![CDATA[<p dir="auto">I am trying to make the ui elements of my window resize according to the window size but all the QWidgets stay the same size.<br />
I have them all in a Horizontal Layout with their sizePolicies set appropriately. Here is my code for resizing the window and widgets:</p>
<pre><code>monitor = screeninfo.get_monitors()[0]
x = monitor.width
y = monitor.height

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

def refreshWindow():
    # pass
    xn = window.width()
    yn = window.height() # TODO
    window.ui.toolList.resize(toolsScale * xn, toolsScale * yn)
    window.ui.imageViewer.resize(mainScale * xn, mainScale * yn)
    window.ui.layerList.resize(layersScale * xn, layersScale * yn)
    # listX = (toolsScale + mainScale) * xn
    # window.ui.layerList.move(listX, 0)
    print(window.ui.layerList.pos())
    window.ui.layerList.show()
    # Resize window and its elements to fit the screen
    window.show()
# Function to refresh window elements

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

    sys.exit(app.exec())

</code></pre>
]]></description><link>https://forum.qt.io/topic/165140/qwidget-modification-at-runtime</link><generator>RSS for Node</generator><lastBuildDate>Sun, 04 Oct 2026 05:19:49 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/165140.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 03 Oct 2026 12:45:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QWidget modification at runtime on Sat, 03 Oct 2026 18:16:04 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Since you have a QMainWindow, is your layout applied to the central widget of your QMainWindow ? Or did you try to change the QMainWindow's own layout which is not possible.</p>
]]></description><link>https://forum.qt.io/post/840357</link><guid isPermaLink="true">https://forum.qt.io/post/840357</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sat, 03 Oct 2026 18:16:04 GMT</pubDate></item></channel></rss>