Qt 高仿QQ窗口抖动效果【原】
来源:互联网 发布:好的招聘软件 编辑:程序博客网 时间:2024/06/06 07:14
2
93
94
95
96
97
98
//头文件YShakeWidget.h
#ifndef YSHAKEWIDGET_H
#define YSHAKEWIDGET_H
#include <QWidget>
class
QTimer;
class
YShakeWidget :
public
QWidget
{
Q_OBJECT
public
:
explicit
YShakeWidget(QWidget *parent = 0);
private
slots:
void
slot_btnTestclicked();
void
slot_timerOut();
private
:
QTimer* m_timer;
int
m_nPosition;
QPoint m_curPos;
};
#endif // YSHAKEWIDGET_H
//实现文件YShakeWidget.cpp
#include "YShakeWidget.h"
#include <QTimer>
#include <QHBoxLayout>
#include <QPushButton>
enum
{MaxLimitTimes = 12};
enum
{MaxLimitSpace = 5};
YShakeWidget::YShakeWidget(QWidget *parent) :
QWidget(parent),
m_timer(
new
QTimer(
this
)),
m_nPosition(0),
m_curPos(QPoint())
{
QPushButton* btnTest =
new
QPushButton(tr(
"Test"
),
this
);
bool
b = connect(btnTest,SIGNAL(clicked()),
this
,SLOT(slot_btnTestclicked()));
Q_ASSERT(b);
QHBoxLayout* hBox =
new
QHBoxLayout(
this
);
hBox->addWidget(btnTest);
this
->setLayout(hBox);
// 计时器
b = connect(m_timer,SIGNAL(timeout()),
this
,SLOT(slot_timerOut()));
Q_ASSERT(b);
m_timer->setInterval(40);
}
void
YShakeWidget::slot_btnTestclicked()
{
m_nPosition = 0;
m_curPos =
this
->pos();
m_timer->start();
}
void
YShakeWidget::slot_timerOut()
{
m_timer->stop();
if
(m_nPosition < MaxLimitTimes)
{
++m_nPosition;
switch
(m_nPosition%4)
{
case
1:
{
QPoint tmpPos(m_curPos.x(),m_curPos.y()-MaxLimitSpace);
this
->move(tmpPos);
}
break
;
case
2:
{
QPoint tmpPos(m_curPos.x()-MaxLimitSpace,m_curPos.y()-MaxLimitSpace);
this
->move(tmpPos);
}
break
;
case
3:
{
QPoint tmpPos(m_curPos.x()-MaxLimitSpace,m_curPos.y());
this
->move(tmpPos);
}
break
;
default
:
case
0:
this
->move(m_curPos);
break
;
}
m_timer->start();
}
}
//main.cpp文件
#include <QtGui/QApplication>
#include "YShakeWidget.h"
int
main(
int
argc,
char
*argv[])
{
QApplication a(argc, argv);
YShakeWidget w;
w.show();
return
a.exec();
}
FROM: http://my.oschina.net/imtoby/blog/104290
0 0
- Qt 高仿QQ窗口抖动效果【原】
- 仿QQ窗口抖动
- Android仿QQ窗口的抖动的动画效果
- Android仿QQ窗口的抖动的动画效果
- JavaScript-仿QQ窗口抖动
- 模拟QQ窗口抖动效果
- c#窗口抖动代码 仿QQ窗口抖动 By:xluo
- 网页用 JavaScript DOM 仿作QQ的窗口抖动效果,超简单~~~
- 网页用 JavaScript DOM 仿作QQ的窗口抖动效果,超简单~~~
- 类似QQ的窗口抖动效果
- JavaScript qq窗口抖动效果
- 高仿QQ(聊天窗口)
- 仿QQ聊天窗口抖动的小程序及源程序
- 一段仿QQ窗口抖动的代码(VC++)
- JavaScript实现的类似腾讯QQ聊天窗口抖动效果
- Android 高仿QQ 界面滑动效果
- Android 高仿QQ 界面滑动效果
- Android 高仿QQ 界面滑动效果
- 【原创】高仿360安全卫士 9.2 界面 (纯qml实现)
- [转]CreateDIBitmap与CreateDIBSection
- 第一个
- 跨域解决方案 & 使用angularJS和jQuery进行Ajax请求的差异
- ThreeMergeOne迭代项目经验
- Qt 高仿QQ窗口抖动效果【原】
- java入门程序100例学习笔记(002九九乘法表)
- cf 581 B.Luxurious Houses
- hdoj 1454&&poj 1039 Pipe 1454 (数学计算几何) 枚举
- android获取图象点阵数组的方法
- 人名币转大写(不完美版)
- Freemarker在web项目中的使用
- Qt之实现360安全卫士主界面(一)
- 值得推荐的C/C++框架和库