窗体部件效果之滚动字幕
2017-08-02 17:50
260 查看
scrollcaption.cpp
#include "widget.h" #include "ui_widget.h" #pragma execution_character_set("utf-8") Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); m_scrollCaptionStr = QStringLiteral("欢迎加入我们:Qt分享&&交流 26197884"); m_timer = new QTimer(this); connect(m_timer, SIGNAL(timeout()), this, SLOT(scrollCaption())); m_timer->start(50); } Widget::~Widget() { delete ui; } void Widget::scrollCaption() { //mothod 1(not sequential) static int nPos = 0; if (nPos > m_scrollCaptionStr.length()) { nPos = 0; } ui->m_scrollCaptionLabel->setText(m_scrollCaptionStr.mid(nPos)); nPos++; //mothod 2(not universal) ui->m_scrollCaptionLabel_2->setText(m_scrollCaptionStr); if(ui->m_scrollCaptionLabel_2->pos().x() + ui->m_scrollCaptionLabel_2->width() < 0) { ui->m_scrollCaptionLabel_2->move(width(), ui->m_scrollCaptionLabel_2->pos().y()); } ui->m_scrollCaptionLabel_2->move(ui->m_scrollCaptionLabel_2->pos().x()-1, ui->m_scrollCaptionLabel_2->pos().y()); }
相关文章推荐
- 一个js实现简单的字幕滚动效果
- CSS3 实现滚动字幕效果(即跑马灯)
- QT制作字幕滚动效果
- C#0010--窗体中的滚动字幕
- 代替marquee的滚动字幕效果代码
- 用js实现字幕滚动效果.
- 代替marquee的滚动字幕效果js代码
- cocos2d-x 利用精灵的可见区域制作字幕滚动效果
- 窗体部件效果之模态
- jquery滚动字幕效果的代码示例
- JQuery自动轮播效果,带字幕说明,带底部滚动圈圈,兼容IE7以上所有主流浏览器。(魔兽背景哟亲)
- 在C# WinForm 轻松实现滚动字幕特效的关于窗体
- JavaScript字幕滚动效果
- 窗体部件效果之窗体置顶
- 用javascript代替marquee的滚动字幕效果代码
- C# WinForm窗体中制作滚动的字幕
- Android 天气预报图文字幕垂直滚动效果
- JavaScript字幕滚动效果
- Android 天气预报图文字幕垂直滚动效果