[英]PyQt4 how to get button size
我已經看到了這 一點,並且我也嘗試過:
self.myButton = QtGui.QPushButton("Click") a = self.myButton.size() print a
這些東西,但我仍然無法獲得單個按鈕的尺寸信息。 我認為,當我print a ,它將返回父窗口的大小。 基本上,它返回的大小顯然不是按鈕的大小,因為返回值太大而無法達到該按鈕的大小。 是的,我覺得這是一個非常新手的問題,但我對此始終感到困惑。 非常感謝您的幫助,在此先感謝您。
print a
您必須將窗口小部件作為父項,或將其置於布局中才能計算其大小。 沒有指定的父母,這有點失落...
...或者更確切地說,它認為它本身將是一個窗口,並針對您所使用的平台使用窗口的最小大小。
希望能有所幫助。
[英]how to get the default size of a window in pyqt4
[英]How to make a button move as the window size is adjusted? (PyQt4)
[英]How to delete a button using PYQT4?
[英]How to add custom button to a QMessageBox in PyQt4
[英]Custom button PyQT4
[英]PyQt4 - How to get the QModelIndex of an element of a model
[英]How to get complete fullscreen with PyQt4
[英]PyQt4 How to get the “text” of a checkbox
[英]How to get PyQt4 working with Spyder
[英]How to get PyQt4 working with PyCharm
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.