本文整理汇总了C++中QMouseEvent::windowPos方法的典型用法代码示例。如果您正苦于以下问题:C++ QMouseEvent::windowPos方法的具体用法?C++ QMouseEvent::windowPos怎么用?C++ QMouseEvent::windowPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMouseEvent
的用法示例。
在下文中一共展示了QMouseEvent::windowPos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool MInverseMouseArea::eventFilter(QObject *obj, QEvent *ev)
{
Q_UNUSED(obj);
if (!m_enabled || !isVisible())
return false;
switch (ev->type()) {
case QEvent::MouseButtonPress: {
QMouseEvent *me = static_cast<QMouseEvent *>(ev);
QPointF mappedPos = me->windowPos();//??is mapping to root item needed still
m_pressed = !isUnderMouse() && !isClickedOnSoftwareInputPanel();
if (m_pressed) {
m_lastsceenPos = me->screenPos();
emit pressedOutside(mappedPos.x(), mappedPos.y());
}
break;
}
case QEvent::MouseMove: {
if (m_pressed) {
QMouseEvent *me = static_cast<QMouseEvent *>(ev);
const QPointF &dist = me->screenPos() - m_lastsceenPos;
if (dist.x() * dist.x() + dist.y() * dist.y() > FlickThresholdSquare)
m_pressed = false;
}
break;
}
case QEvent::MouseButtonRelease: {
QMouseEvent *me = static_cast<QMouseEvent *>(ev);
QPointF mappedPos = mapToRootItem(me->windowPos());
if (m_pressed) {
m_pressed = false;
emit clickedOutside(mappedPos.x(), mappedPos.y());
}
break;
}
default:
break;
}
return false;
}
示例2: if
bool KisInputManager::Private::EventEater::eventFilter(QObject* target, QEvent* event )
{
if ((hungry && (event->type() == QEvent::MouseMove ||
event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonRelease))
// || (peckish && (event->type() == QEvent::MouseButtonPress))
)
{
// Chow down
if (KisTabletDebugger::instance()->debugEnabled()) {
QString pre = QString("[BLOCKED]");
QMouseEvent *ev = static_cast<QMouseEvent*>(event);
dbgTablet << KisTabletDebugger::instance()->eventToString(*ev,pre);
}
peckish = false;
return true;
}
else if ((event->type() == QEvent::MouseButtonPress) /* Need to scrutinize */ &&
(!savedEvent)) /* Otherwise we enter a loop repeatedly storing the same event */
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
// Pocket the event and decide what to do with it later
// savedEvent = *(static_cast<QMouseEvent*>(event));
savedEvent = new QMouseEvent(QEvent::MouseButtonPress,
mouseEvent->pos(),
mouseEvent->windowPos(),
mouseEvent->screenPos(),
mouseEvent->button(),
mouseEvent->buttons(),
mouseEvent->modifiers());
savedTarget = target;
mouseEvent->accept();
return true;
}
return false; // All clear - let this one through!
}
示例3: eventFilter
bool MInverseMouseArea::eventFilter(QObject *obj, QEvent *ev)
{
Q_UNUSED(obj);
if (!m_enabled || !isVisible())
return false;
switch (ev->type()) {
case QEvent::MouseButtonPress: {
QMouseEvent *m = static_cast<QMouseEvent *>(ev);
QPointF pos = mapFromScene(m->windowPos());
bool pressed = !contains(pos);
if (pressed)
emit pressedOutside(pos.x(), pos.y());
break;
}
default:
break;
}
return false;
}