PyQt- Widget 窗体常用属性

myWidget -> setStatusTip ("StatusTip");//状态栏提示
myWidget -> setToolTip ("ToolTip");    //鼠标放到控件上,浮动出一个小黄框。
myWidget -> setWhatsThis ("WhatsThis");//QDialog 标题栏上有一个?按钮,先点按钮鼠标变问号,再点控件。

object name:物件名称
qwidget:enable 使能本部件
geometry:窗口位置和大小设置
sizepolicy:
1. Fixed: 大小不能改变
2. Minimum: 已经是最小, 不能再被缩小, 但能放大.
3. Maximum: 已经是最大, 不能再被放大, 但能缩小.
4. Preferred: 控件的sizeHint()是他的sizeHint, 能被缩小, 放大.
5. Expanding: 控件可以自行增大或者缩小.
Preferred与Expanding的区别: 当有Preferred与Expanding的控件时, 只有Expanding的会被缩小与放大, Preferred的控件使用其sizeHint()作为大小, 大小不发生变化.
sizepolicy:
minisize:最小尺寸
maxsize:最大尺寸
sizeincrement:0*0
basesize:基本大小默认为0 与sizeincrement设置有关
palette:
font:字体
cursor:鼠标形状
mousetracking:
focuspolicy:获取焦点方式(tab键,单击,前两者,。。)
contextmenupolicy:
acceptdrops:支持drop事件
windowtitle:窗体标题
icon:窗体图标左上角的那个
windowopacity:
autofillbackground:自动填充背景色
stylesheet:样式
local:归属地
其他常用属性:
visible                 fullscreen                focus               clearfocus       enabled
show()                 hide()                 raise()               lower()                         close()
MOVEEVENT()     RESIZEEVENT()
注意點:
1,编写程序时,初始化窗体时最好不要使用setGeometry()函数,而用resize()和move()代替,因为使用setGeometry()会导致窗体show()之后再错误的位置上停留很短暂的时间,带来闪烁现象!
Warning: Calling setGeometry() inside resizeEvent() or moveEvent() can lead to infinite recursion.
See the Window Geometry documentation for an overview of geometry issues with windows.
By default, this property contains a value that depends on the user's platform and screen geometry.
Access functions:

const QRect & geometry () const
void setGeometry ( int x, int y, int w, int h )
void setGeometry ( const QRect & )

See also frameGeometry(), rect(), move(), resize(), moveEvent(), resizeEvent(), minimumSize(),
and maximumSize().

猜你喜欢

转载自blog.csdn.net/huolan__34/article/details/81565259