Qt动态靠边收起速度越来越快

a957455952 2016-07-27 09:55:33
#ifndef HIDE_H
#define HIDE_H

#include "box.h"
#include <QTimer>

QTimer *hideTimer = new QTimer;
QTimer *showTimer = new QTimer;


#endif // HIDE_H
/////////////////////////////////////////////
#include "hide.h"

void Box::enterEvent(QEvent *)
{

rect = this->geometry();
rc.setRect(rect.x(),rect.y(),rect.width(),rect.height());
QObject::connect(showTimer, SIGNAL(timeout()), this, SLOT(showSlot()));
if(rect.bottom() < 40)
showTimer->start(15);

}

void Box::leaveEvent(QEvent *)
{
rect = this->geometry();
rc.setRect(rect.x(),rect.y(),rect.width(),rect.height());
QObject::connect(hideTimer, SIGNAL(timeout()), this, SLOT(hideSlot()));
if(rect.top() < 2 && rect.bottom() > 2)
hideTimer->start(30);
}

void Box::hideSlot()
{
rect = this->geometry();
rc.setRect(rect.x(),rect.y(),rect.width(),rect.height());
move(rc.x(),rc.y() - 3);
if(rect.y() + rect.height() < 40)
hideTimer->stop();
}

void Box::showSlot()
{
rect = this->geometry();
rc.setRect(rect.x(),rect.y(),rect.width(),rect.height());
move(rc.x(), rc.y() + 1.5);
if(rect.y() > 0)
showTimer->stop();
}

为什么收起和显示的速度随着操作次数的增多越来越快,求解。
...全文
952 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2016-08-01
  • 打赏
  • 举报
回复
搜“GDI泄露检测”
shiter 2016-07-31
  • 打赏
  • 举报
回复
我猜测是不是操作系统的优化。。。。。

5,530

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 模式及实现
社区管理员
  • 模式及实现社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧