KDE/Qt Tips 004

布局
QLabel
main
关于布局
QVBoxLayout
QHBoxLayout
QGridLayout
Inherits QBoxLayout.
常用的函数:
QLayout ( QWidget * parent, int margin = 0, int spacing = -1, const char * name = 0 )
QLayout ( QLayout * parentLayout, int spacing = -1, const char * name = 0 )
void addChildLayout ( QLayout * l )
The margin is the number of pixels between the edge of the widget and its managed children. The spacing is the default number of pixels between neighboring children. If spacing is -1 the value of margin is used for spacing.

void QLayout::setMenuBar ( QMenuBar * w ) [virtual]
Makes the geometry manager take account of the menu bar w. All child widgets are placed below the bottom edge of the menu bar.
bool QLayout::activate ()
Redoes the layout for mainWidget(). You should generally not need to call this because it is automatically called at the most appropriate times.
However, if you set up a QLayout for a visible widget without resizing that widget, you will need to call this function in order to lay it out.

QBoxLayout ( QWidget * parent, Direction d, int margin = 0, int spacing = -1, const char * name = 0 )
QBoxLayout ( QLayout * parentLayout, Direction d, int spacing = -1, const char * name = 0 )
Inherits QLayout.
Inherited by QHBoxLayout and QVBoxLayout.
void addWidget ( QWidget * widget, int stretch = 0, int alignment = 0 )
void addLayout ( QLayout * layout, int stretch = 0 )

bool setStretchFactor ( QWidget * w, int stretch )
bool setStretchFactor ( QLayout * l, int stretch )

QHBoxLayout ( QWidget * parent, int margin = 0, int spacing = -1, const char * name = 0 )
QHBoxLayout ( QLayout * parentLayout, int spacing = -1, const char * name = 0 )

关于QLabel
setScaledContents( TRUE );//可以使Label内的图像随label大小而拉伸,一直填满label
setPaletteBackgroundPixmap( pix );//拉伸时自动填充label
setPixmap(pix);//拉伸时大小不变

main函数中若
mainWin = new MyWidget;
app.setMainWidget(mainWin);
return app.exec;
程序关闭时不会调MyWidget;的析构函数
除非在app.exec后加上
delete mainWin;
或者
MyWidget mainWin;
app.setMainWidget(&mainWin);
return app.exec;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值