本文整理汇总了C++中QWheelEvent::globalPos方法的典型用法代码示例。如果您正苦于以下问题:C++ QWheelEvent::globalPos方法的具体用法?C++ QWheelEvent::globalPos怎么用?C++ QWheelEvent::globalPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWheelEvent
的用法示例。
在下文中一共展示了QWheelEvent::globalPos方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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);
}
示例3: 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 );
}
示例4: 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);
}
示例5: eventFilter
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
switch(event->type()) {
case QEvent::ToolTip:
{
if (obj != viewer) break;
QHelpEvent* e = static_cast<QHelpEvent*>(event);
if (attributeRect.contains(e->pos())){
QString attribute = viewer->attribute();
if(!attribute.isEmpty())
ToolTip::showText(e->globalPos(),
attribute.prepend("<b>").append("</b>"),
false, 0.8);
}
return true;
}
case QEvent::MouseButtonDblClick:
{
if (obj != viewer && obj != bottomFrame) break;
QMouseEvent *e = static_cast<QMouseEvent*>(event);
if(e->button() & Qt::LeftButton)
changeFullScreen();
return true;
}
case QEvent::ContextMenu:
{
QContextMenuEvent *e = static_cast<QContextMenuEvent*>(event);
showContextMenu(e->globalPos());
return true;
}
case QEvent::Wheel:
{
QWheelEvent *e = static_cast<QWheelEvent *>(event);
// if (e->delta() < 0)
// viewer->nextPic();
// else
// viewer->prePic();
qreal factor = 0.1;
switch(e->modifiers()){
case Qt::ShiftModifier:
factor = e->delta() / qreal(2400); // e->delta() is +120 or -120
break;
case Qt::ControlModifier:
factor = e->delta() / qreal(600);
break;
default:
factor = e->delta() / qreal(1200);
break;
}
viewer->zoomIn(factor, viewer->mapFromGlobal(e->globalPos()));
break;
}
default:
break;
}
return false;
}