Pyqt how to get a widget#39;s dimensions(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.
谢谢
推荐答案
你可以使用frameGeometry 或 geometry 取决于 您的需求.
这篇关于Pyqt如何获取小部件的尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Pyqt如何获取小部件的尺寸
基础教程推荐
- 求两个直方图的卷积 2022-01-01
- 包装空间模型 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
