本文整理汇总了C++中QWheelEvent::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ QWheelEvent::pos方法的具体用法?C++ QWheelEvent::pos怎么用?C++ QWheelEvent::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWheelEvent
的用法示例。
在下文中一共展示了QWheelEvent::pos方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: extractArguments
// Extract event-specific arguments to co::Any array
void EventHub::extractArguments( QEvent* event, co::Any* args, int maxArgs )
{
QEvent::Type ev = event->type();
switch( ev )
{
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseMove:
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>( event );
// extract (x and y), button, modifiers
const QPoint& pos = mouseEvent->pos();
args[0].set( pos.x() );
args[1].set( pos.y() );
args[2].set( static_cast<co::uint32>( ev == QEvent::MouseMove ?
mouseEvent->buttons() : mouseEvent->button() ) );
fillKeyboardModifiers( mouseEvent->modifiers(), args[3] );
}
break;
case QEvent::KeyPress:
case QEvent::KeyRelease:
{
QKeyEvent* keyEvent = static_cast<QKeyEvent*>( event );
fillKeyCodeString( keyEvent->key(), args[0] );
fillKeyboardModifiers( keyEvent->modifiers(), args[1] );
}
break;
case QEvent::Wheel:
{
QWheelEvent* wheelEvent = static_cast<QWheelEvent*>( event );
// extract position (x and y ), delta, modifiers
const QPoint& pos = wheelEvent->pos();
args[0].set( pos.x() );
args[1].set( pos.x() );
args[2].set( wheelEvent->delta() );
fillKeyboardModifiers( wheelEvent->modifiers(), args[3] );
}
break;
case QEvent::Resize:
{
QResizeEvent* resizeEvent = static_cast<QResizeEvent*>( event );
// extract size (width and height) and oldSize (width and height)
const QSize& size = resizeEvent->size();
const QSize& oldSize = resizeEvent->oldSize();
args[0].set( size.width() );
args[1].set( size.height() );
args[2].set( oldSize.width() );
args[3].set( oldSize.height() );
}
break;
default:
// Close, Show and Hide require no arguments
return;
}
}
示例3: eventFilter
bool PopupItem::eventFilter( QObject *object, QEvent *e )
{
MarbleWidget *widget = dynamic_cast<MarbleWidget*> ( object );
if ( !widget ) {
return BillboardGraphicsItem::eventFilter( object, e );
}
if ( e->type() == QEvent::MouseButtonDblClick
|| e->type() == QEvent::MouseMove
|| e->type() == QEvent::MouseButtonPress
|| e->type() == QEvent::MouseButtonRelease )
{
// Mouse events are forwarded to the underlying widget
QMouseEvent *event = static_cast<QMouseEvent*> ( e );
QPoint const shiftedPos = transform( event->pos() );
bool const forcedMouseRelease = m_needMouseRelease && e->type() == QEvent::MouseButtonRelease;
if ( !shiftedPos.isNull() || forcedMouseRelease ) {
if ( !m_needMouseRelease && e->type() == QEvent::MouseButtonPress ) {
m_needMouseRelease = true;
} else if ( forcedMouseRelease ) {
m_needMouseRelease = false;
}
widget->setCursor( Qt::ArrowCursor );
// transform to children's coordinates
QMouseEvent shiftedEvent = QMouseEvent( e->type(), shiftedPos,
event->globalPos(), event->button(), event->buttons(),
event->modifiers() );
if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
widget->setCursor( m_webView->cursor() );
emit dirty();
return true;
}
}
} else if ( e->type() == QEvent::Wheel ) {
// Wheel events are forwarded to the underlying widget
QWheelEvent *event = static_cast<QWheelEvent*> ( e );
QPoint const shiftedPos = transform( event->pos() );
if ( !shiftedPos.isNull() ) {
widget->setCursor( Qt::ArrowCursor );
QWheelEvent shiftedEvent = QWheelEvent( shiftedPos,
event->globalPos(), event->delta(), event->buttons(),
event->modifiers() );
if ( QApplication::sendEvent( m_webView, &shiftedEvent ) ) {
widget->setCursor( m_webView->cursor() );
emit dirty();
return true;
}
}
}
return BillboardGraphicsItem::eventFilter( object, e );
}
示例4: event
bool WebPage::event(QEvent *ev)
{
QMouseEvent* mouseEvent = NULL;
QWheelEvent* wheelEvent = NULL;
QKeyEvent* keyEvent = NULL;
QByteArray byteArray;
QBuffer buffer(&byteArray);
buffer.open(QIODevice::ReadWrite);
QDataStream out(&buffer);
out << (int) ev->type();
switch (ev->type()) {
case QEvent::MouseMove:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonDblClick:
case QEvent::MouseButtonRelease:
if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
return false;
mouseEvent = (static_cast<QMouseEvent*>(ev));
out << mouseEvent->pos() << mouseEvent->globalPos()
<< (int) mouseEvent->button() << (int) mouseEvent->buttons()
<< (int) mouseEvent->modifiers();
OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
break;
case QEvent::Wheel:
if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
return false;;
wheelEvent = (static_cast<QWheelEvent*>(ev));
out << wheelEvent->pos() << wheelEvent->globalPos()
<< wheelEvent->delta() << (int) wheelEvent->buttons()
<< (int) wheelEvent->modifiers() << (int) wheelEvent->orientation();
OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
break;
case QEvent::KeyPress:
case QEvent::KeyRelease:
if (OPNET::OpNetwork::instance()->isReplay() || OPNET::OpNetwork::instance()->isReplica())
return false;
keyEvent = (static_cast<QKeyEvent*>(ev));
out << keyEvent->key() << (int) keyEvent->modifiers()
<< keyEvent->text() << keyEvent->isAutoRepeat()
<< (int) keyEvent->count();
OPNET::OpNetwork::instance()->sendSysCall(MSG_LOG_USER_INPUT, (int) ev->type(), byteArray);
break;
default:
break;
}
return QWebPage::event(ev);
}
示例5: isRecording
/*! Reimplementation of the \c QObject function. Always returns \p false (meaning event is \e not
handled and should be forwarded to the \p qglviewer).
When EventRecorder isRecording(), the following \c QEvent::type are recorded in an internal data
structure: \c KeyPress, \c KeyRelease, \c MouseButtonPress, \c MouseButtonRelease, \c
MouseButtonDblClick, \c MouseMove, \c Wheel and \c Timer (used by QGLViewer::animate()). Does
nothing when isRecording() is \c false.
You may overload this method to filter other \c QEvent::type (your implementation should probably
call this function).
Other specific events can be recorded using recordFrameState() and recordCustomEvent(). */
bool EventRecorder::eventFilter(QObject *, QEvent *e)
{
if (isRecording())
{
bool record = true;
switch (e->type())
{
case QEvent::KeyPress:
case QEvent::KeyRelease:
{
QKeyEvent* ke = (QKeyEvent*)(e);
eventRecords_[eventIndex_].event.keyEvent = new QKeyEvent(e->type(), ke->key(), ke->ascii(), int(ke->state()));
break;
}
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::MouseButtonDblClick:
case QEvent::MouseMove:
{
QMouseEvent* me = (QMouseEvent*)(e);
eventRecords_[eventIndex_].event.mouseEvent = new QMouseEvent(e->type(), me->pos(), int(me->button()), int(me->state()));
break;
}
case QEvent::Wheel:
{
QWheelEvent* we = (QWheelEvent*)(e);
eventRecords_[eventIndex_].event.wheelEvent = new QWheelEvent(we->pos(), we->delta(), int(we->state()));
break;
}
case QEvent::Timer:
{
eventRecords_[eventIndex_].event.keyEvent = NULL; // or any other pointer
break;
}
default:
record = false;
break;
}
if (record)
{
eventRecords_[eventIndex_].type = e->type();
eventRecords_[eventIndex_].time = time_.elapsed();
eventIndex_++;
}
}
return false;
}
示例6: eventFilter
bool
ArtistInfoWidget::eventFilter( QObject* obj, QEvent* event )
{
if ( event->type() == QEvent::Wheel )
{
QWheelEvent* we = static_cast<QWheelEvent*>( event );
QWheelEvent* wheelEvent = new QWheelEvent(
we->pos(),
we->globalPos(),
we->delta(),
we->buttons(),
we->modifiers(),
we->orientation() );
qApp->postEvent( m_area->viewport(), wheelEvent );
event->accept();
return true;
}
else
return QObject::eventFilter( obj, event );
}
示例7: mouseWheelTimerFired
void WebView::mouseWheelTimerFired()
{
pMouseWheelTimer_->stop();
if (mouseWheelEvents_.empty())
return;
int totalDelta = 0;
for (int i = 0; i < mouseWheelEvents_.length(); i++)
{
totalDelta += mouseWheelEvents_.at(i).delta();
}
QWheelEvent event = mouseWheelEvents_.last();
mouseWheelEvents_.clear();
QWheelEvent totalEvent(event.pos(),
event.globalPos(),
totalDelta,
event.buttons(),
event.modifiers(),
event.orientation());
this->QWebView::wheelEvent(&totalEvent);
}
示例8: mouseWheel
void COscScaler::mouseWheel( QEvent * e )
{
QWheelEvent * we = reinterpret_cast< QWheelEvent * >( e );
int numDegrees = we->delta() / 8;
int numSteps = numDegrees / 15;
qreal zoom = (qreal)numSteps;
zoom = ( zoom < 0.0 ) ? m_pd->wheelRatio : (1.0 / m_pd->wheelRatio);
const QPoint & pt = we->pos();
QPointF at = QPointF( m_pd->m_plot->invTransform( QwtPlot::xBottom, pt.x() ),
m_pd->m_plot->invTransform( QwtPlot::yLeft, pt.y() ) );
// Для оси Ox.
qreal boundLow = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->lowerBound() - at.x();
qreal boundHigh = m_pd->m_plot->axisScaleDiv( QwtPlot::xBottom )->upperBound() - at.x();
if ( m_pd->wheelZoomX )
{
boundLow *= zoom;
boundHigh *= zoom;
qreal xMin = boundLow + at.x();
qreal xMax = boundHigh + at.x();
m_pd->m_plot->setAxisScale( QwtPlot::xBottom, xMin, xMax );
emit scaleXChanged( xMin, xMax );
}
// То же для оси Oy.
if ( m_pd->wheelZoomY )
{
boundLow = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->lowerBound() - at.y();
boundHigh = m_pd->m_plot->axisScaleDiv( QwtPlot::yLeft )->upperBound() - at.y();
boundLow *= zoom;
boundHigh *= zoom;
qreal yMin = boundLow + at.y();
qreal yMax = boundHigh + at.y();
m_pd->m_plot->setAxisScale( QwtPlot::yLeft, yMin, yMax );
emit scaleYChanged( yMin, yMax );
}
m_pd->m_plot->replot();
}
示例9: QWheelEvent
RWheelEvent::RWheelEvent(const QWheelEvent& wheelEvent, RGraphicsScene& s,
RGraphicsView& v) :
QWheelEvent(wheelEvent),
RInputEvent(RVector(wheelEvent.pos().x(), wheelEvent.pos().y()), s, v) {
}
示例10: 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;
//.........这里部分代码省略.........