Code: Select all
import sys
from PyQt6.QtWidgets import QApplication, QVBoxLayout, QPushButton, QWidget
from PyQt6.QtCore import QTimer
class MainWindow(QWidget):
def __init__(self):
super().__init__()
self.resize(200, 300)
self.setWindowTitle("Main Window")
layout = QVBoxLayout()
btn = QPushButton("Click", self)
btn.clicked.connect(self.print_geometry)
layout.addWidget(btn)
self.setLayout(layout)
self.show()
def print_geometry(self):
print(self.geometry()) # This will now print the correct geometry
if __name__ == '__main__':
app = QApplication(sys.argv)
win = MainWindow()
sys.exit(app.exec())
Code: Select all
PyQt6.QtCore.QRect(0, 0, 200, 300)
PyQt6.QtCore.QRect(0, 0, 200, 300)
PyQt6.QtCore.QRect(0, 0, 200, 300)
PyQt6.QtCore.QRect(0, 0, 200, 300)
- Betriebssystem: Ubuntu
- Python-Version: 3.9
Mobile version