<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
Hi,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
My specs: Windows 10 x64, Python3.10 x64, PyQt6.3.1<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof">
When clicking the button in the below example, a crash without a traceback occurs:</div>
<blockquote style="margin-top:0;margin-bottom:0">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<span style="font-size: 10pt;">import sys</span>
<div class="ContentPasted0"><span style="font-size: 10pt;">from PyQt6.QtCore import *</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;">from PyQt6.QtGui import *</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;">from PyQt6.QtWidgets import *</span></div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0"><span style="font-size: 10pt;">class TestWindow(QWidget):</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> def __init__(self):</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> super().__init__()</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> self.setFixedSize(640, 480)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> </span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> layout = QVBoxLayout(self)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> layout.setContentsMargins(0, 0, 0, 0)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> layout.setSpacing(0)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> self.setLayout(layout)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> </span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> # Add widgets</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> widgets = [</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("red", "Red"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("green", "Green"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("blue", "Blue"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("violet", "Violet"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("black", "Black"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("orange", "Orange"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("olive", "Olive"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("turquoise", "Turquoise"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ("white", "White"),</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> ]</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> for color, title in widgets:</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> new_widget = QWidget()</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> new_widget.setStyleSheet(f"background: {color};")</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> layout.addWidget(new_widget)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> </span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> # Add a re-arrange button</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> new_button = QPushButton("MOVE WIDGET IN LAYOUT")</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> new_button.clicked.connect(self.move_widget)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> layout.addWidget(new_button)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> </span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> def move_widget(self):</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> item = self.layout().takeAt(2)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> self.layout().insertItem(4, item)</span></div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0"><span style="font-size: 10pt;">def main():</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> app = QApplication(sys.argv)</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> window = TestWindow()</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> window.show()</span></div>
<div class="ContentPasted0"><span style="font-size: 10pt;"> sys.exit(app.exec())</span></div>
<div><br class="ContentPasted0">
</div>
<div class="ContentPasted0"><span style="font-size: 10pt;">if __name__ == "__main__":</span></div>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<span style="font-size: 10pt;"> main()</span></div>
</blockquote>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<span style="font-size: 10pt;"><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<span style="font-size: 12pt;">Is this bug, or am I doing something wrong?<br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<span style="font-size: 12pt;"><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<span style="font-size: 12pt;">Regards,</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof ContentPasted0">
<span style="font-size: 12pt;">Matic<br>
</span></div>
</body>
</html>