processbar 修复位置问题

qt6
ATTIOT\zhengcy 2021-05-17 09:54:55 +08:00
parent 39946eab3c
commit fbe3eca991
2 changed files with 16 additions and 3 deletions

13
Qss.cpp
View File

@ -269,7 +269,7 @@ QssMainWindow::QssMainWindow(QWidget *parent/* = 0*/, Qt::WindowFlags flags/* =
vbox->setMargin(1); vbox->setMargin(1);
vbox->setSpacing(0); vbox->setSpacing(0);
vbox->addWidget(this); vbox->addWidget(this);
// installEventFilter(this);
mFrameRect = m_frame->geometry(); mFrameRect = m_frame->geometry();
m_rcNormal = m_frame->geometry(); m_rcNormal = m_frame->geometry();
@ -1635,6 +1635,7 @@ QSSProcessBar::QSSProcessBar(QWidget *parent) :
setWindowFlags(Qt::FramelessWindowHint); setWindowFlags(Qt::FramelessWindowHint);
this->setModal(true); this->setModal(true);
mParent = parent;
} }
QSSProcessBar::~QSSProcessBar() QSSProcessBar::~QSSProcessBar()
@ -1642,6 +1643,16 @@ QSSProcessBar::~QSSProcessBar()
delete ui; delete ui;
} }
void QSSProcessBar::showEvent(QShowEvent *ev)
{
ui->progressBar->setValue(0);
if(nullptr != mParent){
this->move(mParent->geometry().width()/2 - this->width()/2,
mParent->geometry().height()/2 - this->height()/2);
}
QDialog::showEvent(ev);
}
void QSSProcessBar::on_percent(int percent) void QSSProcessBar::on_percent(int percent)
{ {
ui->progressBar->setValue(percent); ui->progressBar->setValue(percent);

6
Qss.h
View File

@ -1,4 +1,4 @@

#ifndef QSS_H #ifndef QSS_H
#define QSS_H #define QSS_H
@ -423,7 +423,7 @@ class QssMaskWidget : public QWidget
public: public:
QssMaskWidget(QWidget *parent = Q_NULLPTR); QssMaskWidget(QWidget *parent = Q_NULLPTR);
~QssMaskWidget(); virtual ~QssMaskWidget();
virtual bool eventFilter(QObject * obj, QEvent * ev); virtual bool eventFilter(QObject * obj, QEvent * ev);
public: public:
@ -468,12 +468,14 @@ class QSSProcessBar : public QDialog
public: public:
explicit QSSProcessBar(QWidget *parent = nullptr); explicit QSSProcessBar(QWidget *parent = nullptr);
~QSSProcessBar(); ~QSSProcessBar();
void showEvent(QShowEvent *) override;
public slots: public slots:
void on_percent(int); void on_percent(int);
void on_done_close(); void on_done_close();
private: private:
Ui::Process *ui; Ui::Process *ui;
QWidget *mParent;
}; };