/***************************************************************
*Copyright(c) 2014-2015 Company By LH Unigress
*All rights reserved.
*文件名称:流水灯文件
*简要描述:
*
*当前版本:V1.0
*作者:Kelvin Li
*创作日期:2015年4月6日
*说明:
*Email:creazylq@163.com
*QQ:936563422
******************************************************************/
#include "widget.h"
#include <QString>
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
this->setWindowFlags(Qt::FramelessWindowHint);
this->setAttribute(Qt::WA_TranslucentBackground);//窗体背景透明
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;");
this->m_quitButton = new QPushButton(this);
this->m_quitButton->setText("退出");
this->m_quitButton->setToolTip("退出程序");
this->buttonlayout = new QHBoxLayout;
buttonlayout->addStretch(20);
buttonlayout->addWidget(this->m_quitButton);
buttonlayout->addStretch(20);
m_layout = new QVBoxLayout(this);
m_layout->addWidget(m_scrollCaptionLabel);
//m_layout->addWidget(this->m_quitButton);
m_layout->addLayout(this->buttonlayout);
m_layout->setContentsMargins(0,0,0,0);
setLayout(this->m_layout);
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);
}
Widget::~Widget()
{
}
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;
}
- 1
- 2
前往页