QT学习记录-进度条:
2013-01-30 10:11
253 查看
QT学习记录-进度条:
在QT中可以用QProgressBar或着QProgressDialog来实现进度条。
QProgressDialog:
QProgressBar:
在QT中可以用QProgressBar或着QProgressDialog来实现进度条。
QProgressDialog:
QProgressBar:
// progress.h #ifndefPROGRESS_H #definePROGRESS_H #include<QtGui/QMainWindow> #include<QPushButton> #include<QProgressBar> #include<QProgressDialog> #include<QVBoxLayout> classprogress:publicQMainWindow { Q_OBJECT public: progress(QWidget*parent=0); publicslots: voidbarstart(void); private: QPushButton*startbutton; QProgressBar*bar; QProgressDialog*process; }; #endif//PROGRESS_H // progress.cpp #include"progress.h" #include<windows.h> progress::progress(QWidget*parent) :QMainWindow(parent) { resize(500,150); startbutton=newQPushButton("clickme!",this); bar=newQProgressBar(this); startbutton->setGeometry(30,20,100,30); bar->setGeometry(30,100,300,20); connect(startbutton,SIGNAL(clicked()),this,SLOT(barstart())); } voidprogress::barstart(void) { #if1 //QProgressBar unsignedinti,j; bar->setRange(0,5000-1); for(i=0;i<5000;i++) { //for(j=0;j<5000;j++); //Sleep(10); bar->setValue(i); } #else //QProgressDialog对话框的形式 QProgressDialogprocess(this); process.setLabelText(tr("processing...")); process.setRange(0,5000-1); process.setModal(true); process.setCancelButtonText(tr("cancel")); for(inti=0;i<5000;i++) { for(intj=0;j<20000;j++); process.setValue(i); if(process.wasCanceled()) break; } #endif }
相关文章推荐
- 学习Qt的小技巧记录(一)——菜鸡的修炼之路
- QT学习记录
- Qt学习记录(一)——Helloword
- 【QT5】学习记录1
- 学习记录-Qt环境的编译
- Qt4.8.6数据库驱动连接记录(本文只为记录学习过程,没有侵犯他人权利意思)
- Qt学习记录--03 Qt的信号槽的使用
- 学习记录-Qt的多工程管理
- 学习进度条记录
- QT学习记录(1)-控件 QPushButton, QLineEdit, QLabel, QHBoxLayout, QGridLayout
- Qt学习——进度条QProgressBar/QProgressDialog类
- Qt学习记录
- 学习记录-Qt按键单击后延迟一段时间触发下一个函数执行
- QT学习点滴记录(五)
- QT学习 常见操作记录
- 学习记录-Qt编写自定义控件
- QT学习进程记录1:学写Helloworld
- Qt————学习记录(四)
- 学习记录-Qt获取文件路径
- QT学习记录