91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

實(shí)現(xiàn)觸摸屏QT滾動(dòng)區(qū)手指下滑自動(dòng)滾動(dòng)。qt版本5.5.1。需繼承帶有滾動(dòng)區(qū)域的原生QT類,重載mousePressEvent,mouseMoveEvent。并開啟 setMouseTracking(true)。

資源截圖

代碼片段和文件信息

#include?“gzscrollarea.h“
#include?
#include?
#include?
#include?

GZScrollArea::GZScrollArea(QWidget?*parent)?:
????QScrollArea(parent)
{
????m_Body?=?new?QWidget(this);
????this->setWidget(m_Body);
????//setAttribute(Qt::WA_Hover?true);
????this->setMouseTracking(true);
}

void?GZScrollArea::setGZGeometry(int?x?int?y?int?w?int?h)
{
????this->setGeometry(x?y?w?h);
????m_Body->setGeometry(0?0?w?y);
}


QWidget*?GZScrollArea::getBody()
{
????return?m_Body;
}

//記錄起始位置
void?GZScrollArea::mousePressEvent(QMouseEvent?*event)
{
????m_TempPoint?=?event->pos();
}

//滑動(dòng)鼠標(biāo)下位
void?GZScrollArea::mouseMoveEvent(QMouseEvent?*event)
{
????auto?pos????=?event->pos();

????auto?vbar???=?this->verticalScrollBar();
????//向下滑動(dòng)?向下滾動(dòng)
????//auto?offset?=?pos->y()?-?m_TempPoint.y();
????//向上滑動(dòng)?向下滾動(dòng)
????auto?offset?=?m_TempPoint.y()?-?pos.y();
????//獲取當(dāng)前滾動(dòng)條位置
????auto?val????=?vbar->value();
????//獲取滾動(dòng)條pagetemp區(qū)域高度
????auto?step???=?vbar->pageStep();
????//設(shè)計(jì)移動(dòng)位置
????auto?move???=?offset?*?step?/?m_Body->height();
????if(move?+?val??m_Body->height())?return;
????//移動(dòng)
????vbar->setValue(move?+?val);
}


評論

共有 條評論