Learning PyQt5 (two): PyQt5 layout manager

 

As shown, there is a dialog box with a button in the form of templates, respectively, without the dialog box with buttons, window, widget

Here we create a window.

A layout into Vertical (vertical layout), Horizontal (lateral arrangement), the Grid (grid layout), Form1 (form layout)

Why do we want to make layout? Because we want to be able to change with the size of the buttons the size of the window changes

As shown, we add three buttons on the Select All, click there will be a vertical layout,

This is a relatively simple way to set other layout is similar, you can follow your own design ideas page.

When we finished the layout, you can use Ctrl + R preview, I will return to find the window button and change has not changed, it is because I do not have the layout of the form may not be set

 

FIG flag can directly click, select a layout softened, may be horizontal, vertical, any one of the grid (the same effect).

 At this point you have completed all the layout, press CTRL + R Preview when widening the window, all components will change with the window changes.

When we completed a preliminary layout, you can click to select a control, in the right side of the property bar, set the properties, and thus change the layout fine

We have a button as an example:

  • QObject
    • The name of the object name, both control: objectName
  • QWidget
    • enabled: This is a switch to turn the button click, the converse is not optional
    • geometry: geometrically, provided X, Y, width, height parameter values ​​directly fillable
    • sizePolicy: horizontal policy, policy vertical, horizontal stretching, vertical stretching, by definition, set the display size of the button in different layouts

       

    • minimumSize: minimum size, the default is 0,0
    • maximumSize: The maximum size
    • sizeIncrement: increase the size
    • baseSize: basic dimensions
    • palette: palette
    • font: font style buttons
    • cursor: Select this mouse is suspended style
    • mouseTracking: mouse tracking
    • tabletTracking: flat track
    • focusPolicy: focus policy
    • contextMenuPolicy: Menu Strategy
    • acceptDrops: receiving decline (not know with what)
    • toolTip: tooltip
    • toolTipDuration:工具提示持续时间
    • statusTip:状态提示
    • whatsThis:whats is This
    • accessibleName:名
    • accessibleDescription:描述
    • layoutDirection:布局方向
    • autoFillBackground:自动填充背景
    • styleSheet:sheet样式
    • locale:语音
    • inputMethodHInts:输入法提示
  • QAbstractButton
    • text:文本
    • icon:图片
    • iconSize:图片大小
    • shortcut:快捷键
    • checkable:可点击否?
    • checked:点击状态
    • autoRepeat:自动重复
    • autoExclusive:自动唯一
    • autoRepeatDelay:自动重复延迟
    • autoRepeatInterval:自动重复间隔
  • QPushBUtton
    • autoDefault:自动默认
    • default:默认
    • flat:平(不突出按钮) 

其中,布局的属性有这个是布局的比例,比较有用。

 

Guess you like

Origin www.cnblogs.com/gexbooks/p/11281391.html