本文整理汇总了C++中QMouseEvent::screenPos方法的典型用法代码示例。如果您正苦于以下问题:C++ QMouseEvent::screenPos方法的具体用法?C++ QMouseEvent::screenPos怎么用?C++ QMouseEvent::screenPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMouseEvent
的用法示例。
在下文中一共展示了QMouseEvent::screenPos方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) {
if (!filterEnabled(originalDestination, event)) {
return false;
}
#ifdef DEBUG
// Don't intercept our own events, or we enter an infinite recursion
{
auto rootItem = _sharedObject->getRootItem();
auto quickWindow = _sharedObject->getWindow();
QObject* recurseTest = originalDestination;
while (recurseTest) {
Q_ASSERT(recurseTest != rootItem && recurseTest != quickWindow);
recurseTest = recurseTest->parent();
}
}
#endif
switch (event->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease: {
event->ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), event)) {
return event->isAccepted();
}
break;
}
case QEvent::Wheel: {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos());
QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(),
wheelEvent->orientation());
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos());
QMouseEvent mappedEvent(mouseEvent->type(), transformedPos, mouseEvent->screenPos(), mouseEvent->button(),
mouseEvent->buttons(), mouseEvent->modifiers());
if (event->type() == QEvent::MouseMove) {
// TODO - this line necessary for the QML Tooltop to work (which is not currently being used), but it causes interface to crash on launch on a fresh install
// need to investigate into why this crash is happening.
//_qmlContext->setContextProperty("lastMousePosition", transformedPos);
}
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
default:
break;
}
return false;
}
示例2: pointerEvent
void QEGLPlatformCursor::pointerEvent(const QMouseEvent &event)
{
if (event.type() != QEvent::MouseMove)
return;
const QRect oldCursorRect = cursorRect();
m_cursor.pos = event.screenPos().toPoint();
update(oldCursorRect | cursorRect());
m_screen->handleCursorMove(m_cursor.pos);
}
示例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 *me = static_cast<QMouseEvent *>(ev);
QPointF mappedPos = me->screenPos();//??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->screenPos());
if (m_pressed) {
m_pressed = false;
emit clickedOutside(mappedPos.x(), mappedPos.y());
}
break;
}
default:
break;
}
return false;
}
示例4: 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!
}
示例5: eventFilter
bool OffscreenSurface::eventFilter(QObject* originalDestination, QEvent* event) {
if (!filterEnabled(originalDestination, event)) {
return false;
}
#ifdef DEBUG
// Don't intercept our own events, or we enter an infinite recursion
{
auto rootItem = _sharedObject->getRootItem();
auto quickWindow = _sharedObject->getWindow();
QObject* recurseTest = originalDestination;
while (recurseTest) {
Q_ASSERT(recurseTest != rootItem && recurseTest != quickWindow);
recurseTest = recurseTest->parent();
}
}
#endif
switch (event->type()) {
case QEvent::KeyPress:
case QEvent::KeyRelease: {
event->ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), event)) {
return event->isAccepted();
}
break;
}
case QEvent::Wheel: {
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(wheelEvent->pos());
QWheelEvent mappedEvent(transformedPos, wheelEvent->delta(), wheelEvent->buttons(), wheelEvent->modifiers(),
wheelEvent->orientation());
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
case QEvent::MouseMove: {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
QPointF transformedPos = mapToVirtualScreen(mouseEvent->localPos());
QMouseEvent mappedEvent(mouseEvent->type(), transformedPos, mouseEvent->screenPos(), mouseEvent->button(),
mouseEvent->buttons(), mouseEvent->modifiers());
mappedEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &mappedEvent)) {
return mappedEvent.isAccepted();
}
break;
}
#if defined(Q_OS_ANDROID)
case QEvent::TouchBegin:
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
QTouchEvent *originalEvent = static_cast<QTouchEvent *>(event);
QEvent::Type fakeMouseEventType = QEvent::None;
Qt::MouseButton fakeMouseButton = Qt::LeftButton;
Qt::MouseButtons fakeMouseButtons = Qt::NoButton;
switch (event->type()) {
case QEvent::TouchBegin:
fakeMouseEventType = QEvent::MouseButtonPress;
fakeMouseButtons = Qt::LeftButton;
break;
case QEvent::TouchUpdate:
fakeMouseEventType = QEvent::MouseMove;
fakeMouseButtons = Qt::LeftButton;
break;
case QEvent::TouchEnd:
fakeMouseEventType = QEvent::MouseButtonRelease;
fakeMouseButtons = Qt::NoButton;
break;
}
// Same case as OffscreenUi.cpp::eventFilter: touch events are always being accepted so we now use mouse events and consider one touch, touchPoints()[0].
QMouseEvent fakeMouseEvent(fakeMouseEventType, originalEvent->touchPoints()[0].pos(), fakeMouseButton, fakeMouseButtons, Qt::NoModifier);
fakeMouseEvent.ignore();
if (QCoreApplication::sendEvent(_sharedObject->getWindow(), &fakeMouseEvent)) {
/*qInfo() << __FUNCTION__ << "sent fake touch event:" << fakeMouseEvent.type()
<< "_quickWindow handled it... accepted:" << fakeMouseEvent.isAccepted();*/
return fakeMouseEvent.isAccepted();
}
break;
}
case QEvent::InputMethod:
case QEvent::InputMethodQuery: {
auto window = getWindow();
if (window && window->activeFocusItem()) {
event->ignore();
if (QCoreApplication::sendEvent(window->activeFocusItem(), event)) {
bool eventAccepted = event->isAccepted();
if (event->type() == QEvent::InputMethodQuery) {
QInputMethodQueryEvent *imqEvent = static_cast<QInputMethodQueryEvent *>(event);
// this block disables the selection cursor in android which appears in
// the top-left corner of the screen
if (imqEvent->queries() & Qt::ImEnabled) {
imqEvent->setValue(Qt::ImEnabled, QVariant(false));
}
}
return eventAccepted;
}
return false;
//.........这里部分代码省略.........
示例6: eventFilter
bool MainWindow::eventFilter(QObject *, QEvent *event)
{
QMouseEvent *mos = dynamic_cast <QMouseEvent*>(event);
QKeyEvent *kp = dynamic_cast <QKeyEvent*>(event);
if(event->type() == QEvent::MouseButtonPress)
{
if( gamepause == false )
{
if( mos->button() == Qt::LeftButton )
{
// 滑鼠在彈弓的鳥上
if( mos->screenPos().x() > 248 && mos->screenPos().x() <= 284 )
{
if( mos->screenPos().y() > 430 && mos->screenPos().y() <= 463 )
{
line1->setLine(-10,-10,-10,-10);
line2->setLine(-10,-10,-10,-10);
line1->show();
line2->show();
ready = true;
return true;
}
}
else
{
// 避免 buttons 誤觸 skill
if( mos->screenPos().y() > 195 )
{
if( skillused == false )
{
bird[num+1]->skill();
if(num == 0)
{
egg = new Egg(bird[num+1]->getPosition().x, bird[num+1]->getPosition().y-3, 0.1f, &timer, QPixmap(":/image/egg.png"), world, scene);
egg->setLinearVelocity(b2Vec2(0, 5));
itemList.push_back(egg);
eggexist = true;
}
if(num == 2)
{
float bx = bird[num+1]->getPosition().x;
float by = bird[num+1]->getPosition().y;
int vx = bird[num+1]->getLinearVelocity().x;
int vy = bird[num+1]->getLinearVelocity().y;
blue1 = new Bluebird(bx, by+2, 0.4f, &timer, QPixmap(":/image/BlueBird.png"), world, scene);
blue1->setLinearVelocity(b2Vec2(vx, vy+2));
itemList.push_back(blue1);
blue2 = new Bluebird(bx, by-2, 0.4f, &timer, QPixmap(":/image/BlueBird.png"), world, scene);
blue2->setLinearVelocity(b2Vec2(vx, vy-2));
itemList.push_back(blue2);
cloneexist = true;
}
if(num == 1)
{
float bx = bird[num+1]->getPosition().x;
float by = bird[num+1]->getPosition().y;
int vx = bird[num+1]->getLinearVelocity().x;
int vy = bird[num+1]->getLinearVelocity().y;
delete bird[num+1];
big = new Bigbird(bx, by, 0.8f, &timer, QPixmap(":/image/BigBirds.png"), world, scene);
big->setLinearVelocity(b2Vec2(vx, vy));
itemList.push_back(big);
bigexist = true;
}
skillused = true;
}
}
}
}
}
//cout << "Now event x: " << mos->screenPos().x()<< " event y: " << mos->screenPos().y() << endl;
//std::cout << "Press !" << std::endl ;
return false;
}
if(event->type() == QEvent::MouseMove)
{
if(ready == true)
{
if( mos->screenPos().x() > 122 && mos->screenPos().x() <= 284 )
{
if( mos->screenPos().y() > 360 && mos->screenPos().y() <= 528 )
{
line2->setLine(mos->screenPos().x()-100,mos->screenPos().y()-100,190,330);
line1->setLine(mos->screenPos().x()-100,mos->screenPos().y()-100,156,330);
setbird[num]->setPos(mos->screenPos().x()-112,mos->screenPos().y()-140);
launch = true;
return true;
}
}
}
//std::cout << "Move !" << std::endl ;
return false;
}
if(event->type() == QEvent::MouseButtonRelease)
{
if( launch == true )
{
scene->removeItem(setbird[num]);
delete setbird[num];
float a , b;
//.........这里部分代码省略.........