QT进度条QProgressBar的练习(定制QProgressBar,单独成为一个控件)
2016-10-24 20:56
387 查看
progressbar.h
progressbar.cpp
main.cpp
转自:http://blog.chinaunix.net/uid-27225886-id-3352398.html
http://www.cnblogs.com/luoxiang/p/4159881.html
#ifndef PROGRESSBAR_H #define PROGRESSBAR_H #include <QProgressBar> class QString; class ProgressBar: public QProgressBar { Q_OBJECT public: ProgressBar(QWidget *parent = 0):QProgressBar(parent){} QString strText; public slots: void stepOne(); }; #endif // PROGRESSBAR_H
progressbar.cpp
#include "progressbar.h" #include <QString> void ProgressBar::stepOne() { if(this->value()+1 <= this->maximum()) { this->setValue(this->value()+1); strText = "QProgressBar Test : "+this->text(); this->setWindowTitle(strText); } else { this->setValue(this->minimum()); } }
main.cpp
#include <QApplication> #include <QTimer> #include "progressbar.h" int main(int argc, char**argv) { QApplication app(argc, argv); //progressBar ProgressBar *progressBar = new ProgressBar; progressBar->setWindowTitle("QProgressBar Test"); progressBar->resize(400,40); progressBar->setMaximum(100); progressBar->setMinimum(0); progressBar->setValue(0); //define a timer QTimer *timer = new QTimer; timer->start(500); QObject::connect(timer, SIGNAL(timeout()), progressBar, SLOT(stepOne())); progressBar->show(); return app.exec(); }
转自:http://blog.chinaunix.net/uid-27225886-id-3352398.html
http://www.cnblogs.com/luoxiang/p/4159881.html
相关文章推荐
- 练习2-6:修改Fillvector.cpp使它能把vector中的所有元素连接成单独的一个字符串,并打印,但不要加上行号。
- 将分页作为一个单独的控件
- 自己使用js/jquery写的一个定制对话框控件
- 我写的一个Qt 显示二维码( QR Code)的控件
- 如何开发一个Qt工具箱内的控件
- 错误:在一个线程上创建的控件不能成为在另一个线程控件的父级(处理方法)
- 我写的一个 Qt 显示图片的控件
- ASPNET服务端控件练习(一个机试题)
- 一个显示 OpenCV Mat 图像的自定义 Qt 控件
- QT5.3 杂记 Qt5下,QWidget系列从QtGui中被剥离出去,成为单独的QtWidget模块。随着Qt Quick2的引入,QtDeclarative也逐渐和QWidget系列也脱离关系。
- 实例 XPages 开发一个通用的 Dojo Tree 风格定制控件
- QT练习4:编写一个查找对话框
- 把控件中的代码剥离出来单独成一个dll
- js/jquery写的一个定制对话框控件
- 介绍一个基于QT的源代码编辑器控件QScintilla
- 将分页作为一个单独的控件
- Visual C# 2005 - 如何将 DataGridView 控件单独截取成一个位图文件
- 我写的一个 Qt 显示图片的控件