QT状态栏QStatusBar

来源:互联网 发布:淘宝靠谱吉他 编辑:程序博客网 时间:2024/05/22 05:11

状态栏显示的信息分3种
1. 一般信息,用QLabel 代表
2.  永久信息,文本会一直显示在状态栏的最右边。

3. 临时信息,指定信息现实的时间。时间到即信息消失

 

locationLabel_ = new QLabel("July");

//locationLabel_ = new QLabel;

locationLabel_->setAlignment(Qt::AlignCenter);  //水平居中(HCenter)。

//locationLabel->setMinimumSize(200,15);   //设置控件最小尺度

locationLabel_->setMinimumSize(locationLabel_->sizeHint());

 

aixLabel_ = new QLabel("\"CTRL + H\" for help");

//Optional

//statusBar()->setStyleSheet(QString("QStatusBar::item{border: 0px}")); // 设置不显示label的边框

statusBar()->setSizeGripEnabled(false); //设置是否显示右边的大小控制点

 

statusBar()->addWidget(locationLabel_);

//statusBar()->addWidget(aixLabel_, 1);

 

QLabel *per1 = new QLabel("Ready1", this);

QLabel *per2 = new QLabel("Ready2", this);

QLabel *per3 = new QLabel("Ready3", this);

statusBar()->addPermanentWidget(per1); //现实永久信息

statusBar()->addPermanentWidget(per2);

statusBar()->insertPermanentWidget(2, per3);

statusBar()->showMessage("Status is here...", 3000); // 显示临时信息,时间3秒钟.

 

QStatusBar右下角的大小控制点可以通过setSizeGripEnabled()函数来设置是否存在,详情参见API文档。
由于QStatusBar可以添加多个QWidget,因此,我们可以构建出很复杂的状态栏。
0 0
原创粉丝点击