forked from Longxr/QtCustomProgressbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogressdialog.cpp
51 lines (42 loc) · 1.08 KB
/
progressdialog.cpp
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
41
42
43
44
45
46
47
48
49
50
51
#include "progressdialog.h"
#include "ui_progressdialog.h"
#include <QPainter>
ProgressDialog::ProgressDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::ProgressDialog)
{
ui->setupUi(this);
setAttribute(Qt::WA_TranslucentBackground, true);
setWindowFlags(Qt::Window | Qt::FramelessWindowHint
| Qt::WindowSystemMenuHint | Qt::WindowMinimizeButtonHint
| Qt::WindowMaximizeButtonHint);
ui->progressBar->setValue(0);
}
ProgressDialog::~ProgressDialog()
{
delete ui;
}
void ProgressDialog::paintEvent(QPaintEvent *)
{
QStyleOption opt;
opt.init(this);
QPainter p(this);
style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this);
}
void ProgressDialog::setValue(int percent)
{
ui->progressBar->setValue(percent);
}
void ProgressDialog::setTitle(QString title)
{
ui->titleName->setText(title);
}
void ProgressDialog::setProgressText(QString text)
{
ui->progressLabel->setText(text);
}
void ProgressDialog::on_cancleButton_clicked()
{
ui->progressBar->setValue(0);
emit cancled();
}