当前位置: 首页>>代码示例>>C++>>正文


C++ QMouseEvent::buttons方法代码示例

本文整理汇总了C++中QMouseEvent::buttons方法的典型用法代码示例。如果您正苦于以下问题:C++ QMouseEvent::buttons方法的具体用法?C++ QMouseEvent::buttons怎么用?C++ QMouseEvent::buttons使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QMouseEvent的用法示例。


在下文中一共展示了QMouseEvent::buttons方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: eventFilter

bool Window::eventFilter(QObject *object, QEvent *event)
 {
    if(!mouseOn || object != this) return false;
     if (event->type() == QEvent::MouseButtonPress) {
         QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
         if (mouseEvent->buttons() & Qt::LeftButton) {
             mouse[0] = true;
             return true;
         }
         if (mouseEvent->buttons() & Qt::RightButton) {
             mouse[1] = true;
             return true;
         }
     }
     if (event->type() == QEvent::MouseButtonRelease) {
         QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
         if (mouseEvent->buttons() & Qt::LeftButton) {
             mouse[0] = false;
             return true;
         }
         if (mouseEvent->buttons() & Qt::RightButton) {
             mouse[1] = false;
             return true;
         }
     }
     return false;
 }
开发者ID:jackokring,项目名称:sleepdream,代码行数:27,代码来源:window.cpp

示例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;
    }
}
开发者ID:DaveDubUK,项目名称:hifi,代码行数:31,代码来源:MouseEvent.cpp

示例3: eventFilter

bool MouseEventFilter::eventFilter(QObject *obj, QEvent *event)
{
    if(event->type() == QEvent::MouseMove)
    {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        if(mouseEvent)
        {
            ApplicationManager::singleton()->setMouseX(mouseEvent->pos().x());
            ApplicationManager::singleton()->setMouseY(mouseEvent->pos().y());

            if(mouseEvent->buttons() && Qt::LeftButton && ApplicationManager::singleton()->grabbingWindowMoveHandle() &&
                    ApplicationManager::singleton()->windowControlButtonsEnabled())
            {
                QPoint diffPosition = mouseEvent->pos() - mousePos.toPoint();
                QPoint newPosition = ApplicationManager::singleton()->window()->position() + diffPosition;

                int oldWindowWidth = ApplicationManager::singleton()->window()->width();
                if(ApplicationManager::singleton()->showNormal())
                {
                    int windowWidth = ApplicationManager::singleton()->window()->width();
                    ApplicationManager::singleton()->window()->setPosition(newPosition.x() + (oldWindowWidth - windowWidth) * (mousePos.x() / oldWindowWidth), newPosition.y());
                    mousePos.setX(mousePos.x() - (oldWindowWidth - windowWidth) * (mousePos.x() / oldWindowWidth));
                }
                else
                {
                    ApplicationManager::singleton()->window()->setPosition(newPosition);
                }
            }
            else if(mouseEvent->buttons() && Qt::LeftButton && ApplicationManager::singleton()->grabbingWindowResizeHandle() &&
                    ApplicationManager::singleton()->windowControlButtonsEnabled())
            {
                QPoint diffPosition = mouseEvent->pos() - mousePos.toPoint();
                mousePos = mouseEvent->pos();

                QWindow *window = ApplicationManager::singleton()->window();
                int newWidth = window->width() + diffPosition.x();
                int newHeight = window->height() + diffPosition.y();

                if(newWidth < 1024) newWidth = 1024;
                if(newHeight < 600) newHeight = 600;

                window->setGeometry(window->position().x(), window->position().y(), newWidth, newHeight);
            }
        }
    }
    else if(event->type() == QEvent::MouseButtonPress)
    {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
        if(mouseEvent)
        {
            mousePos = mouseEvent->pos();
        }
    }
    return QObject::eventFilter(obj, event);
}
开发者ID:andresilvasantos,项目名称:beatwhale,代码行数:55,代码来源:mouseeventfilter.cpp

示例4: if

PlatformMouseEvent::PlatformMouseEvent(QInputEvent* event, int clickCount)
{
    m_timestamp = WTF::currentTime();

    QMouseEvent* me = 0;

    switch (event->type()) {
    case QEvent::MouseMove:
        m_eventType = MouseEventMoved;
        me = static_cast<QMouseEvent *>(event);
        break;
    case QEvent::MouseButtonDblClick:
    case QEvent::MouseButtonPress:
        m_eventType = MouseEventPressed;
        me = static_cast<QMouseEvent *>(event);
        break;
    case QEvent::MouseButtonRelease:
        m_eventType = MouseEventReleased;
        me = static_cast<QMouseEvent *>(event);
        break;
#ifndef QT_NO_CONTEXTMENU
    case QEvent::ContextMenu: {
        m_eventType = MouseEventPressed;
        QContextMenuEvent* ce = static_cast<QContextMenuEvent*>(event);
        m_position = IntPoint(ce->pos());
        m_globalPosition = IntPoint(ce->globalPos());
        m_button = RightButton;
        break;
    }
#endif // QT_NO_CONTEXTMENU
    default:
        m_eventType = MouseEventMoved;
    }

    if (me) {
        m_position = IntPoint(me->pos());
        m_globalPosition = IntPoint(me->globalPos());

        if (me->button() == Qt::LeftButton || (me->buttons() & Qt::LeftButton))
            m_button = LeftButton;
        else if (me->button() == Qt::RightButton || (me->buttons() & Qt::RightButton))
            m_button = RightButton;
        else if (me->button() == Qt::MidButton || (me->buttons() & Qt::MidButton))
            m_button = MiddleButton;
        else
            m_button = NoButton;
    }

    m_clickCount = clickCount;
    m_shiftKey =  (event->modifiers() & Qt::ShiftModifier);
    m_ctrlKey = (event->modifiers() & Qt::ControlModifier);
    m_altKey =  (event->modifiers() & Qt::AltModifier);
    m_metaKey = (event->modifiers() & Qt::MetaModifier);
}
开发者ID:DreamOnTheGo,项目名称:src,代码行数:54,代码来源:PlatformMouseEventQt.cpp

示例5: 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);
}
开发者ID:catedrasaes-umu,项目名称:openhmitester,代码行数:30,代码来源:qteventconsumer.cpp

示例6: eventFilter

bool AppInit::eventFilter(QObject *obj, QEvent *evt)
{
    QWidget *w = (QWidget *)obj;
    if (!w->property("CanMove").toBool()) {
        return QObject::eventFilter(obj, evt);
    }

    QMouseEvent *event = static_cast<QMouseEvent *>(evt);
    if (event->type() == QEvent::MouseButtonPress) {
        if (event->button() == Qt::LeftButton) {
            mousePressed = true;
            mousePoint = event->globalPos() - w->pos();
            return true;
        }
    } else if (event->type() == QEvent::MouseButtonRelease) {
        mousePressed = false;
        return true;
    } else if (event->type() == QEvent::MouseMove) {
        if (mousePressed && (event->buttons() && Qt::LeftButton)) {
            w->move(event->globalPos() - mousePoint);
            return true;
        }
    }

    return QObject::eventFilter(obj, evt);
}
开发者ID:zhoajianjun,项目名称:QT,代码行数:26,代码来源:appinit.cpp

示例7: eventFilter

bool DialogFunction::eventFilter(QObject* pWatched, QEvent* pEvent)
{
	QwtPlotCanvas* pPlotCanvas = static_cast<QwtPlotCanvas*>(pWatched);
	switch (pEvent->type())
	{
	case QEvent::MouseButtonPress:
		{
			QMouseEvent* pMouseEvent = static_cast<QMouseEvent*>(pEvent);
			Qt::MouseButtons buttons = pMouseEvent->buttons();
			if (buttons & Qt::RightButton)
			{
				QMenu menu;

				// Insert point action
				QAction* pActionInsertPoint = new QAction(tr("Insert point"), &menu);
				pActionInsertPoint->setData(pMouseEvent->pos());
				connect(pActionInsertPoint, SIGNAL(triggered(bool)), this, SLOT(onInsertPoint()));
				menu.addAction(pActionInsertPoint);

				// Remove point action
				if (_indexSelectedPoint>=0)
				{
					QAction* pActionRemovePoint = new QAction(tr("Remove point"), &menu);
					pActionRemovePoint->setData(pMouseEvent->pos());
					connect(pActionRemovePoint, SIGNAL(triggered(bool)), this, SLOT(onRemovePoint()));
					menu.addAction(pActionRemovePoint);
				}

				menu.exec(QCursor::pos());
			}
			else if (buttons & Qt::LeftButton && _indexSelectedPoint >=0)
开发者ID:FromtonRouge,项目名称:eProDrums,代码行数:31,代码来源:DialogFunction.cpp

示例8: eventFilter

bool HScrollArea::eventFilter(QObject *obj, QEvent *event)
{
    if (event->type() == QEvent::MouseMove) {
        QMouseEvent* me = (QMouseEvent*) event;
        if ((me->buttons() & Qt::LeftButton)) {
            if (!mMoveStart) {
                mMoveStart = true;
                mContinousMove =false;
                mMousePoint = me->globalPos();
            }
            else {
                scrollBar = horizontalScrollBar();
                QPoint p = me->globalPos();
                int offset = p.x() - mMousePoint.x();
                if( !mContinousMove && ( offset > -10 && offset < 10 ) )
                    return false;

                mContinousMove = true;

                scrollBar->setValue(scrollBar->value() - offset);
                mMousePoint = p;
            }
            return true;
        }
    }
    else if (event->type() == QEvent::MouseButtonRelease) {
        mMoveStart = false;
    }
    return QObject::eventFilter(obj, event);
}
开发者ID:liduoyou,项目名称:FBSV3,代码行数:30,代码来源:HScrollArea.cpp

示例9: 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 ();
    }
  }
开发者ID:MahaKoala,项目名称:dilay,代码行数:29,代码来源:move-camera.cpp

示例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());
            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;
}
开发者ID:howard-stearns,项目名称:hifi,代码行数:60,代码来源:OffscreenSurface.cpp

示例11: 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;
    }
}
开发者ID:coral-framework,项目名称:coral-qt,代码行数:60,代码来源:EventHub.cpp

示例12: 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);
}
开发者ID:Earthwings,项目名称:marble,代码行数:58,代码来源:FileViewFloatItem.cpp

示例13: 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);
}
开发者ID:thdtjsdn,项目名称:Marble-1,代码行数:58,代码来源:WidgetGraphicsItem.cpp

示例14: storeMouseState

void GAllEvents::storeMouseState(QEvent *event)
{
        QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
	this->nX = mouseEvent->x();
	this->nY = mouseEvent->y();
	this->nGlobalX = mouseEvent->globalX();
	this->nGlobalY = mouseEvent->globalY();
	this->nButton = mouseEvent->button();
	this->nButtons = mouseEvent->buttons();
}
开发者ID:MajdiSobain,项目名称:ring,代码行数:10,代码来源:gallevents.cpp

示例15: eventFilter

bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
	QPushButton *pBut = (QPushButton*)obj;
	QString objName = pBut->objectName();
	int index = 0;
	if ( objName.compare("pushButton_0") == 0 ) index = DISPLAYTYPE;
	else if( objName.compare("pushButton_1") == 0 ) index = DISPLAYTYPE1;
	else if( objName.compare("pushButton_2") == 0 ) index = DISPLAYTYPE2;
	else if( objName.compare("pushButton_3") == 0 ) index = DISPLAYTYPE3;
	else if( objName.compare("pushButton_4") == 0 ) index = DISPLAYTYPE4;
	else if( objName.compare("pushButton_5") == 0 ) index = DISPLAYTYPE5;
	else if( objName.compare("pushButton_6") == 0 ) index = DISPLAYTYPE6;
	else if( objName.compare("pushButton_7") == 0 ) index = DISPLAYTYPE7;
	else if( objName.compare("pushButton_8") == 0 ) index = DISPLAYTYPE8;
	else if( objName.compare("pushButton_9") == 0 ) index = DISPLAYTYPE9;
	else if( objName.compare("pushButton_10") == 0 ) index = DISPLAYTYPE10;
	else if( objName.compare("pushButton_11") == 0 ) index = DISPLAYTYPE11;
	else if( objName.compare("pushButton_12") == 0 ) index = DISPLAYTYPE12;
	else if( objName.compare("pushButton_13") == 0 ) index = DISPLAYTYPE13;
	else if( objName.compare("pushButton_14") == 0 ) index = DISPLAYTYPE14;
	else if( objName.compare("pushButton_15") == 0 ) index = DISPLAYTYPE15;
	else if( objName.compare("pushButton_16") == 0 ) index = DISPLAYTYPE16;
	else if( objName.compare("pushButton_17") == 0 ) index = DISPLAYTYPE17;
	else index = -1;

	QString passwd = passWord.at(index);
	if(event->type()==QEvent::MouseButtonPress && pBut -> isEnabled() && (index < DISPLAYTOT || index >= DISPLAYTYPE))
	{
		QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
		if (mouseEvent->buttons() & Qt::LeftButton) 
		{
			if(passwd.compare("") != 0)
			{
				//qDebug("Password: %s", passwd.toStdString().c_str());
#if 0
				Password pword(passwd, new QWidget());
				if(pword.getStatus()== true) displayDockWidget(index, pBut);
#endif
#if 1
				displayDockWidget(index, pBut);
#endif
			}
			else
			{
				displayDockWidget(index, pBut);
			}
			return true;
		}
		return false;
	} 

	return QMainWindow::eventFilter(obj, event);
}
开发者ID:Sangil-Lee,项目名称:RefCode,代码行数:53,代码来源:MainWindow.cpp


注:本文中的QMouseEvent::buttons方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。