Search code examples
pythonwidgetsizepyqt

Pyqt how to get a widget's dimensions


I am currently developing an application in which i cannot use modal windows (due to some application constraints). However, in some cases i would like to simulate a popup window. To do so i dynamically create a widget that has the centralwidget as parent and i use the move() method to place it where i want. I would like to know if there is a way to get a widget's dimensions at a given time (considering the mainWindow can be resized at any time) so that i will be able to center the placeholder popup (a simple widget) at the middle of the centralwidget.

Thank you


Solution

  • You can use frameGeometry or geometry depending on your needs.