Actually, how can I extract size of gui elements in general in PyQt?

So far I have only found sizeHint mentioning anything regarding sizes in PyQt.

Could anyone please explain how sizes works in PyQt?

有帮助吗?

解决方案

In general, it's not possible to guarantee the exact sizes of widgets, because there are so many different factors that come in to play. Widgets will rendered differently depending on the window manager in use, the current GUI style, the fonts, etc - and each platform has it's own peculiarities.

To get a better understanding of all this, I would suggest you take a look at Qt's own overviews of window geometry, widgets and layouts and layout management.

To answer the specific question on the height of QListWidgetItems: they will have whatever height is calculated by the QListWidget when it lays out its items. This may take into account the items' sizeHint, which can be set programmatically with QListWidgetItem.setSizeHint.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top