本文整理汇总了C++中QMouseEvent::modifiers方法的典型用法代码示例。如果您正苦于以下问题:C++ QMouseEvent::modifiers方法的具体用法?C++ QMouseEvent::modifiers怎么用?C++ QMouseEvent::modifiers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMouseEvent
的用法示例。
在下文中一共展示了QMouseEvent::modifiers方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCursor
void Interactor2DNavigate::UpdateCursor( QEvent* event, QWidget* wnd )
{
if ( wnd->hasFocus() )
{
if ( event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonRelease ||
event->type() == QEvent::MouseMove)
{
QMouseEvent* e = ( QMouseEvent* )event;
if ( e->button() == Qt::MidButton || e->button() == Qt::RightButton ||
( ( e->modifiers() & CONTROL_MODIFIER) && (e->modifiers() & Qt::ShiftModifier) ) )
{
Interactor2D::UpdateCursor( event, wnd );
}
else
{
// set own cursor
wnd->setCursor( QCursor() );
}
}
}
else
{
Interactor2D::UpdateCursor( event, wnd );
}
}
示例2: x
MouseEvent::MouseEvent(const QMouseEvent& event, const unsigned int deviceID) :
x(event.x()),
y(event.y()),
deviceID(deviceID),
isLeftButton(event.buttons().testFlag(Qt::LeftButton)),
isRightButton(event.buttons().testFlag(Qt::RightButton)),
isMiddleButton(event.buttons().testFlag(Qt::MiddleButton)),
isShifted(event.modifiers().testFlag(Qt::ShiftModifier)),
isControl(event.modifiers().testFlag(Qt::ControlModifier)),
isMeta(event.modifiers().testFlag(Qt::MetaModifier)),
isAlt(event.modifiers().testFlag(Qt::AltModifier))
{
// single button that caused the event
switch (event.button()) {
case Qt::LeftButton:
button = "LEFT";
isLeftButton = true;
break;
case Qt::RightButton:
button = "RIGHT";
isRightButton = true;
break;
case Qt::MiddleButton:
button = "MIDDLE";
isMiddleButton = true;
break;
default:
button = "NONE";
break;
}
}
示例3: mouseMoveEvent
void mouseMoveEvent (State& state, const QMouseEvent& event) {
if (event.buttons () == Qt::MiddleButton) {
Camera& cam = state.camera ();
const glm::uvec2& resolution = cam.resolution ();
glm::ivec2 newPos = ViewUtil::toIVec2 (event);
glm::ivec2 delta = newPos - oldPos;
if (event.modifiers () == Qt::NoModifier) {
if (delta.x != 0) {
cam.verticalRotation ( 2.0f * glm::pi <float> ()
* this->rotationFactor
* float (-delta.x) / float (resolution.x));
}
if (delta.y != 0) {
cam.horizontalRotation ( 2.0f * glm::pi <float> ()
* this->rotationFactor
* float (-delta.y) / float (resolution.y));
}
}
else if (event.modifiers () == Qt::ShiftModifier) {
cam.setGaze ( cam.gazePoint ()
+ (this->movementFactor * float ( delta.x) * cam.right ())
+ (this->movementFactor * float (-delta.y) * cam.up ())
);
}
this->oldPos = newPos;
state.mainWindow ().mainWidget ().glWidget ().update ();
}
}
示例4: 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;
}
示例5: eventFilter
bool ProgressManagerPrivate::eventFilter(QObject *obj, QEvent *event)
{
if (obj == m_statusBarWidget && event->type() == QEvent::Enter) {
m_hovered = true;
updateVisibility();
} else if (obj == m_statusBarWidget && event->type() == QEvent::Leave) {
m_hovered = false;
// give the progress view the chance to get the mouse enter event
updateVisibilityWithDelay();
} else if (obj == m_statusBarWidget && event->type() == QEvent::MouseButtonPress
&& !m_taskList.isEmpty()) {
QMouseEvent *me = static_cast<QMouseEvent *>(event);
if (me->button() == Qt::LeftButton && !me->modifiers()) {
FutureProgress *progress = m_currentStatusDetailsProgress;
if (!progress)
progress = m_taskList.last();
// don't send signal directly from an event filter, event filters should
// do as little a possible
QTimer::singleShot(0, progress, &FutureProgress::clicked);
event->accept();
return true;
}
}
return false;
}
示例6: handleMouseDoubleEvent
void QtEventConsumer::handleMouseDoubleEvent ( QObject *obj, QEvent *event )
{
// check the object
QWidget *widget = isValidWidget(obj);
if (!widget){
DEBUG(D_CONSUMER,"(QtEventConsumer::handleMouseDoubleEvent) No widget to handle");
return;
}
DEBUG(D_CONSUMER,"(QtEventConsumer::handleMouseDoubleEvent)");
QMouseEvent *me = dynamic_cast< QMouseEvent*> ( event );
//create the event
QOE::QOE_MouseDouble qoe;
qoe.timestamp(_timer.restart());
completeBasicData(qoe,widget,me);
qoe.button(me->button());
qoe.buttons(me->buttons());
qoe.modifiers(me->modifiers());
///sensitive value
completeSensitiveData(qoe, widget);
//send event if qoe is valid
if (isValidQOE(qoe) && isValidQOEMouse(qoe))
sendNewTestItem(qoe);
}
示例7: eventFilter
bool BookmarkWidget::eventFilter(QObject *object, QEvent *e)
{
if ((object == this) || (object == treeView->viewport())) {
QModelIndex index = treeView->currentIndex();
if (e->type() == QEvent::KeyPress) {
QKeyEvent *ke = static_cast<QKeyEvent*>(e);
if (index.isValid() && searchField->text().isEmpty()) {
const QModelIndex &src = filterBookmarkModel->mapToSource(index);
if (ke->key() == Qt::Key_F2) {
QStandardItem *item =
bookmarkManager->treeBookmarkModel()->itemFromIndex(src);
if (item) {
item->setEditable(true);
treeView->edit(index);
item->setEditable(false);
}
} else if (ke->key() == Qt::Key_Delete) {
bookmarkManager->removeBookmarkItem(treeView, src);
}
}
switch (ke->key()) {
default: break;
case Qt::Key_Up: {
case Qt::Key_Down:
treeView->subclassKeyPressEvent(ke);
} break;
case Qt::Key_Enter: {
case Qt::Key_Return:
index = treeView->selectionModel()->currentIndex();
if (index.isValid()) {
QString data = index.data(Qt::UserRole + 10).toString();
if (!data.isEmpty() && data != QLatin1String("Folder"))
emit requestShowLink(data);
}
} break;
case Qt::Key_Escape: {
emit escapePressed();
} break;
}
} else if (e->type() == QEvent::MouseButtonRelease) {
if (index.isValid()) {
QMouseEvent *me = static_cast<QMouseEvent*>(e);
bool controlPressed = me->modifiers() & Qt::ControlModifier;
if(((me->button() == Qt::LeftButton) && controlPressed)
|| (me->button() == Qt::MidButton)) {
QString data = index.data(Qt::UserRole + 10).toString();
if (!data.isEmpty() && data != QLatin1String("Folder"))
{
//CentralWidget::instance()->setSourceInNewTab(data);
emit requestShowLinkInNewTab(data);
}
}
}
}
}
return QWidget::eventFilter(object, e);
}
示例8: eventFilter
bool ContentWindow::eventFilter(QObject *o, QEvent *e)
{
if (m_contentWidget && o == m_contentWidget->viewport()
&& e->type() == QEvent::MouseButtonRelease) {
QMouseEvent *me = static_cast<QMouseEvent*>(e);
QItemSelectionModel *sm = m_contentWidget->selectionModel();
if (!me || !sm)
return QWidget::eventFilter(o, e);
Qt::MouseButtons button = me->button();
const QModelIndex &index = m_contentWidget->indexAt(me->pos());
if (index.isValid() && sm->isSelected(index)) {
if ((button == Qt::LeftButton && (me->modifiers() & Qt::ControlModifier))
|| (button == Qt::MidButton)) {
QHelpContentModel *contentModel =
qobject_cast<QHelpContentModel*>(m_contentWidget->model());
if (contentModel) {
QHelpContentItem *itm = contentModel->contentItemAt(index);
if (itm && HelpViewer::canOpenPage(itm->url().path()))
OpenPagesManager::instance().createPage(itm->url());
}
} else if (button == Qt::LeftButton) {
itemClicked(index);
}
}
}
return QWidget::eventFilter(o, e);
}
示例9: 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;
}
}
示例10: eventFilter
bool FileViewFloatItem::eventFilter(QObject *object, QEvent *e)
{
if ( !enabled() || !visible() ) {
return false;
}
MarbleWidget *widget = dynamic_cast<MarbleWidget*> (object);
if ( !widget ) {
return AbstractFloatItem::eventFilter(object, e);
}
if ( m_marbleWidget != widget ) {
// Delayed initialization
m_marbleWidget = widget;
}
Q_ASSERT( m_marbleWidget );
// Mouse events are forwarded to the underlying widget
QMouseEvent *event = static_cast<QMouseEvent*> (e);
QRectF floatItemRect = QRectF( positivePosition(), size() );
QPoint shiftedPos = event->pos() - floatItemRect.topLeft().toPoint()
- QPoint( padding(), padding() );
if( e->type() == QEvent::MouseMove ) {
m_itemPosition = event->globalPos();
}
if( floatItemRect.contains( event->pos() ) ) {
QWidget *child = m_fileViewParent->childAt( shiftedPos );
if( child ) {
m_marbleWidget->setCursor( Qt::ArrowCursor );
// there needs to be some extra handling for the scrollbars
// these need some special treatment due to them not forwarding
// their mouseevents to their scrollbars.
if( reinterpret_cast<QScrollBar*>( child ) == m_fileView->horizontalScrollBar() ) {
shiftedPos -= QPoint( 0, m_fileView->viewport()->size().height() );
} else if( reinterpret_cast<QScrollBar*>( child ) == m_fileView->verticalScrollBar() ) {
shiftedPos -= QPoint( m_fileView->viewport()->size().width(), 0 );
}
QMouseEvent shiftedEvent( e->type(), shiftedPos,
event->globalPos(), event->button(), event->buttons(),
event->modifiers() );
if( QApplication::sendEvent(child, &shiftedEvent) ) {
if( e->type() == QEvent::MouseButtonPress ||
e->type() == QEvent::MouseButtonRelease ||
e->type() == QEvent::MouseButtonDblClick ||
e->type() == QEvent::MouseMove )
updateFileView();
return true;
}
}
}
return AbstractFloatItem::eventFilter(object, e);
}
示例11: eventFilter
bool WidgetGraphicsItem::eventFilter( QObject *object, QEvent *e )
{
if ( !visible() || d->m_widget == 0 ) {
return false;
}
MarbleWidget *widget = dynamic_cast<MarbleWidget*> (object);
if ( !widget ) {
return ScreenGraphicsItem::eventFilter(object, e);
}
if ( d->m_marbleWidget != widget ) {
// Delayed initialization
d->m_marbleWidget = widget;
}
Q_ASSERT(d->m_marbleWidget);
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 );
QList<QPointF> widgetPositions = absolutePositions();
QRectF widgetItemRect;
QPoint shiftedPos;
QList<QPointF>::iterator it = widgetPositions.begin();
bool foundRightPosition = false;
while( it != widgetPositions.end() && !foundRightPosition ) {
widgetItemRect = QRectF( *it, size() );
if ( widgetItemRect.contains( event->pos() ) ) {
foundRightPosition = true;
shiftedPos = event->pos() - widgetItemRect.topLeft().toPoint();
}
}
if ( foundRightPosition ) {
QWidget *child = d->m_widget->childAt( shiftedPos );
if ( child ) {
d->m_marbleWidget->setCursor( Qt::ArrowCursor );
shiftedPos -= child->pos(); // transform to children's coordinates
QMouseEvent shiftedEvent = QMouseEvent( e->type(), shiftedPos,
event->globalPos(), event->button(), event->buttons(),
event->modifiers() );
if ( QApplication::sendEvent( child, &shiftedEvent ) ) {
return true;
}
}
}
}
return ScreenGraphicsItem::eventFilter(object, e);
}
示例12: eventFilter
bool GooeyDoubleSpinBox::eventFilter(QObject* object, QEvent* event)
{
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
switch(event->type())
{
case QEvent::MouseButtonPress:
if(mouseEvent->button() == Qt::LeftButton)
{
_lastMousePos = mouseEvent->globalPos();
}
break;
case QEvent::MouseButtonRelease:
if(mouseEvent->button() == Qt::LeftButton)
{
_lastMousePos = QPoint(); // Reset the point !
}
break;
case QEvent::MouseMove:
if(mouseEvent->buttons() & Qt::LeftButton)
{
QPoint pos = mouseEvent->globalPos();
double dx = _spinBox->singleStep() * (pos.x() - _lastMousePos.x());
if(mouseEvent->modifiers() & Qt::CTRL)
{
dx *= 2.0;
}
else if(mouseEvent->modifiers() & Qt::SHIFT)
{
dx *= 0.5;
}
_spinBox->setValue( _spinBox->value() + dx );
// Update position !
_lastMousePos = pos;
}
break;
default:
break;
}
return false;
}
示例13: eventFilter
bool MainWindow::eventFilter(QObject *, QEvent *e){
if(e->type() == QEvent::MouseButtonRelease){
QMouseEvent *me = static_cast<QMouseEvent*>(e);
if(me->modifiers() == Qt::ControlModifier){
qDebug() << "Ctrl+Left Click";
editFlag = true;
}
}
return false;
}
示例14: if
void Interactor2DMeasure::UpdateCursor( QEvent* event, QWidget* wnd )
{
RenderView2D* view = ( RenderView2D* )wnd;
if ( wnd->hasFocus() )
{
if ( event->type() == QEvent::MouseButtonPress ||
event->type() == QEvent::MouseButtonRelease ||
event->type() == QEvent::MouseMove)
{
QMouseEvent* e = ( QMouseEvent* )event;
if ( ( ( e->button() == Qt::MidButton || e->button() == Qt::RightButton ) && !m_bEditing ) ||
( ( e->modifiers() & CONTROL_MODIFIER) && (e->modifiers() & Qt::ShiftModifier) ) )
{
Interactor2D::UpdateCursor( event, wnd );
return;
}
else if ( ( !m_bEditing && !m_bDrawing && view->GetRegion( e->x(), e->y() ) ) ||
( m_bEditing && m_nPointIndex < 0 ) )
{
wnd->setCursor( CursorFactory::CursorGrab );
}
else
{
if ( m_nAction == MM_Line )
{
wnd->setCursor( CursorFactory::CursorMeasureLine );
}
else if ( m_nAction == MM_Rectangle )
{
wnd->setCursor( CursorFactory::CursorMeasureRectangle );
}
else if ( m_nAction == MM_Polyline || m_nAction == MM_Spline )
{
wnd->setCursor( CursorFactory::CursorMeasurePolyline );
}
}
}
}
else
{
Interactor2D::UpdateCursor( event, wnd );
}
}
示例15: eventFilter
bool LeftClickWithModifiersEater::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick)
{
QMouseEvent *me = static_cast<QMouseEvent *>(event);
if(me->button() == Qt::LeftButton && me->modifiers() != Qt::NoModifier)
return true;
}
return QObject::eventFilter(obj, event);
}