Fix RollingMessageWidget can not rolling.
This commit is contained in:
@@ -6,8 +6,8 @@
|
|||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QDebug>
|
|
||||||
#include <QShowEvent>
|
#include <QShowEvent>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const int WAIT_TIMES = 60;
|
const int WAIT_TIMES = 60;
|
||||||
@@ -146,6 +146,11 @@ QString RollingMessageWidget::getNextMessage() {
|
|||||||
|
|
||||||
void RollingMessageWidget::showEvent(QShowEvent *event) {
|
void RollingMessageWidget::showEvent(QShowEvent *event) {
|
||||||
QWidget::showEvent(event);
|
QWidget::showEvent(event);
|
||||||
|
QTimer::singleShot(1000, this, &RollingMessageWidget::initDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RollingMessageWidget::initDelay()
|
||||||
|
{
|
||||||
if (!mInitFlag)
|
if (!mInitFlag)
|
||||||
{
|
{
|
||||||
TOTAL_ROLL_DISTANCE = this->width();
|
TOTAL_ROLL_DISTANCE = this->width();
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public:
|
|||||||
protected:
|
protected:
|
||||||
void timerEvent(QTimerEvent* event) override ;
|
void timerEvent(QTimerEvent* event) override ;
|
||||||
void showEvent(QShowEvent *event) override ;
|
void showEvent(QShowEvent *event) override ;
|
||||||
|
void initDelay();
|
||||||
QString getNextMessage();
|
QString getNextMessage();
|
||||||
private:
|
private:
|
||||||
int mTimerId = -1;
|
int mTimerId = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user