ilstam
ilstam

Reputation: 1594

how to get the default size of a window in pyqt4

When I create a QMainWindow without explicitly specifying its dimensions, PyQt will give it a -let's say- "standard size" which is not the minimum that the window can get.

Can I set this size at will in any way?

My goal is to get this "standard size" according to the currently visible widgets, when I set the visibility of some widgets on/off.

Upvotes: 0

Views: 2132

Answers (3)

three_pineapples
three_pineapples

Reputation: 11849

You want to look at QWidget.normalGeometry(). Note, the widget (or in this case, QMainWindow) must be first shown for this to return something other than (0,0)

Upvotes: 1

Nejat
Nejat

Reputation: 32645

QWidget.sizeHint holds the recommended size for the widget. It's default implementation returns the layout's preferred size if the widget has a layout. So if your dialog has a layout, just use sizeHint to get the recommended size which is the default one.

Upvotes: 1

klitz1967
klitz1967

Reputation: 255

You might try this command to set size:

QMainWindow.setIconSize (self, QSize iconSize)

Alternatively, one can set a size with the given width and height using:

PySide.QtCore.QSize.setWidth() PySide.QtCore.QSize.setHeight()

Upvotes: 0

Related Questions