由于是动态图片,显示的时候就要用到QMovie进行加载,简单的代码如下所示:
1
2
3
4
5
6
7
8
9
|
QMovie *move =
new
QMovie(:/images/splash.gif);
QLabel *label =
new
QLabel(,
0
);
label->setWindowIcon(QIcon(:/images/main.png));
label->setAttribute(Qt::WA_TranslucentBackground,
true
);
//窗体背景透明
label->setGeometry(
510
,
300
,
450
,
100
);
label->setMovie(move);
move->start();
label->setWindowFlags(Qt::FramelessWindowHint);
label->show();
|
设置窗体透明
1
2
|
this
->setWindowFlags(Qt::FramelessWindowHint);
this
->setAttribute(Qt::WA_TranslucentBackground);
//窗体背景透明
|
1
2
3
4
|
this
->m_scrollCaptionLabel =
new
QLabel(
this
);
this
->m_scrollCaptionLabel->setToolTip(模拟流水灯效果);
this
->m_scrollCaptionLabel->setFont(QFont(Times,
30
,QFont::Bold));
this
->m_scrollCaptionLabel->setStyleSheet(color: blue;);
|
1
2
3
4
5
|
m_scrollCaptionStr = QString(欢迎加入我们:技术在于分享、交流
936563422
);
QTimer *m_timer =
new
QTimer(
this
);
QObject::connect(m_timer,SIGNAL(timeout()),
this
,SLOT(slot_scrollCaption()));
QObject::connect(
this
->m_quitButton,SIGNAL(clicked()),
this
,SLOT(close()));
m_timer->start(
500
);
|
1
2
3
4
5
6
7
8
9
10
11
12
|
void
Widget::slot_scrollCaption()
{
static
int
nPos =
0
;
if
(nPos > m_scrollCaptionStr.length())
{
nPos =
0
;
}
this
->m_scrollCaptionLabel->setText(
this
->m_scrollCaptionStr.mid(nPos));
++nPos;
}
|