Fix RollingMessageWidget can not rolling.

This commit is contained in:
sunwen
2023-08-24 17:17:08 +08:00
parent 236e1e84a2
commit 92ee79a3f7
2 changed files with 7 additions and 1 deletions

View File

@@ -6,8 +6,8 @@
#include <QLabel>
#include <QThread>
#include <QDebug>
#include <QShowEvent>
#include <QTimer>
namespace {
const int WAIT_TIMES = 60;
@@ -146,6 +146,11 @@ QString RollingMessageWidget::getNextMessage() {
void RollingMessageWidget::showEvent(QShowEvent *event) {
QWidget::showEvent(event);
QTimer::singleShot(1000, this, &RollingMessageWidget::initDelay);
}
void RollingMessageWidget::initDelay()
{
if (!mInitFlag)
{
TOTAL_ROLL_DISTANCE = this->width();

View File

@@ -31,6 +31,7 @@ public:
protected:
void timerEvent(QTimerEvent* event) override ;
void showEvent(QShowEvent *event) override ;
void initDelay();
QString getNextMessage();
private:
int mTimerId = -1;