Pyqt如何获取小部件的尺寸 [英] Pyqt how to get a widget's dimensions

查看:33
本文介绍了Pyqt如何获取小部件的尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个无法使用模式窗口的应用程序(由于某些应用程序限制).但是,在某些情况下,我想模拟一个弹出窗口.为此,我动态创建了一个以 centralwidget 作为父级的小部件,并使用 move() 方法将其放置在我想要的位置.我想知道是否有办法在给定时间获取小部件的尺寸(考虑到 mainWindow 可以随时调整大小),以便我能够将占位符弹出窗口(一个简单的小部件)居中中央小部件.

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.

谢谢

推荐答案

你可以使用frameGeometrygeometry 取决于 您的需求.

这篇关于Pyqt如何获取小部件的尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆