Qt流水效果

由于是动态图片,显示的时候就要用到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); //窗体背景透明
添加label用于显示文字并对文字设置简单的效果
?
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;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值