#include "BusyIndicator.h" #include #include #include BusyIndicator::BusyIndicator(QWidget* parent) : QWidget { parent } { setAttribute(Qt::WA_TransparentForMouseEvents); QLabel* icon = new QLabel; icon->resize(80, 80); QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); icon->setSizePolicy(sizePolicy); _busy_movie = new QMovie(":gif/BusyIndicator.gif"); // 转圈 GIF icon->setMovie(_busy_movie); _busy_movie->start(); QLabel* text = new QLabel(QStringLiteral(u"加载数据中......")); QVBoxLayout* layout = new QVBoxLayout(this); layout->addStretch(); layout->addWidget(icon, 0, Qt::AlignCenter); layout->addWidget(text, 0, Qt::AlignCenter); layout->addStretch(); setLayout(layout); } void BusyIndicator::Start() { // _busy_movie->start(); this->setVisible(true); this->update(); } void BusyIndicator::Stop() { // _busy_movie->stop(); this->setVisible(false); this->update(); }