1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| #include "taskbarprogress.h" #include "ui_taskbarprogress.h" TaskbarProgress::TaskbarProgress(QWidget *parent) : QMainWindow(parent), ui(new Ui::TaskbarProgress) { ui->setupUi(this); timer = new QTimer; timer->setInterval(1000); windowsTaskbarButton = new QWinTaskbarButton(this); connect(timer, &QTimer::timeout, this, &TaskbarProgress::onTimeout); connect(ui->Btn_Start, &QAbstractButton::clicked, this, &TaskbarProgress::onButtonClicked); } TaskbarProgress::~TaskbarProgress() { delete ui; } void TaskbarProgress::onButtonClicked() { windowsTaskbarButton->setWindow(windowHandle()); windowsTaskbarProgress = windowsTaskbarButton->progress(); windowsTaskbarProgress->setRange(0, 100); timer->start(); } void TaskbarProgress::onTimeout() { windowsTaskbarProgress->setValue(windowsTaskbarProgress->value() + 20); windowsTaskbarProgress->show(); if (windowsTaskbarProgress->value() > 99) { windowsTaskbarProgress->setValue(0); timer->stop(); } }
|