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


C++ QMouseEvent类代码示例

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


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

示例1: switch

bool HelpBrowser::eventFilter(QObject *object, QEvent *event)
{
    if (object == mWebView) {
        switch (event->type()) {
        case QEvent::MouseButtonPress: {
            QMouseEvent * mouseEvent = static_cast<QMouseEvent*>(event);
            switch (mouseEvent->button()) {
            case Qt::XButton1:
                mWebView->pageAction(QWebPage::Back)->trigger();
                return true;

            case Qt::XButton2:
                mWebView->pageAction(QWebPage::Forward)->trigger();
                return true;

            default:
                break;
            }
            break;
        }
        case QEvent::ShortcutOverride: {
            QKeyEvent * kevent = static_cast<QKeyEvent*>(event);
            if ( kevent == QKeySequence::Copy ||
                 kevent == QKeySequence::Paste )
            {
                kevent->accept();
                return true;
            }
            break;
        }
        default:
            break;
        }
    }
    return false;
}
开发者ID:SpaceAppsXploration,项目名称:supercollider,代码行数:36,代码来源:help_browser.cpp

示例2: rectLeft

bool MoveDelegate::editorEvent(QEvent *event, QAbstractItemModel *, const QStyleOptionViewItem &option, const QModelIndex &index)
{
    QRect rect = option.rect;
    QRect rectLeft(rect.x() + rect.width()/4 - 8, rect.y() + rect.height()/2 - 5 , 30, 15);
    QRect rectRight(rect.x() + rect.width()*3/4 -8, rect.y() + rect.height()/2 - 5 , 30, 15);

    if (event->type() == QEvent::MouseMove) {
//        QMouseEvent* e =(QMouseEvent*)event;
    }

    if (event->type() == QEvent::MouseButtonRelease) {
        QMouseEvent* e =(QMouseEvent*)event;
        int row = index.row();
        if (rectLeft.contains(e->x(), e->y())) {
            emit left(row);
            return true;
        }
        else if(rectRight.contains(e->x(), e->y())){
            emit right(row);
            return true;
        }
    }
    return false;
}
开发者ID:JinduYin,项目名称:YQCSongsMaintain,代码行数:24,代码来源:yqcdelegate.cpp

示例3: if

bool Nepomuk::AnnotationDelegate::editorEvent( QEvent* event, QAbstractItemModel* model, const QStyleOptionViewItem& option, const QModelIndex& index )
{
    if ( event->type() == QEvent::MouseButtonPress ) {
        QMouseEvent* me = static_cast<QMouseEvent*>( event );
        if ( me->button() == Qt::LeftButton ) {
            if ( plusRect( option ).contains( me->pos() ) ) {
                kDebug() << "Clicked plus";
                Annotation* anno = index.data( AnnotationModel::AnnotationRole ).value<Nepomuk::Annotation*>();
                anno->create( d->resource );
                delete anno;
                return true;
            }
            else if ( minusRect( option ).contains( me->pos() ) ) {
                kDebug() << "Clicked minus";
                Annotation* anno = index.data( AnnotationModel::AnnotationRole ).value<Nepomuk::Annotation*>();
                anno->setUserRelevance( 0.0 );
                delete anno;
                return true;
            }
        }
    }

    return false;
}
开发者ID:KDE,项目名称:nepomukannotation,代码行数:24,代码来源:annotationdelegate.cpp

示例4: mouseReleased

bool ComboBoxItemDelegate::mouseReleased(QEvent * event)
{
    if (event->type() != QEvent::MouseButtonRelease)
        return false;

    QAbstractItemModel* model = mCombo->model();
    QMouseEvent *ev = static_cast<QMouseEvent*>(event);
    QModelIndex index = mCombo->view()->indexAt(ev->pos());
    QVariant removable = index.data(ITEM_REMOVABLE_ROLE);
    bool remove = true;
    if (removable.type() == QVariant::Bool)
        remove = removable.toBool();

    if (remove && mLastIndex == index && model && index.data(Qt::UserRole).toString() != INVALID_DATA) {
        QStyleOptionMenuItem opt = getStyleOption(mLastStyleOption, index);
        int height = opt.rect.height();
        if (ev->x() >= opt.rect.width()-height) {
            emit removeItem(index.row());
            return true;
        }
    }

    return false;
}
开发者ID:fr33mind,项目名称:Belle,代码行数:24,代码来源:combobox.cpp

示例5: switch

//=============================================================================
//	eControl::paintEvent
//-----------------------------------------------------------------------------
bool eControl::event(QEvent* event)
{
	switch(event->type())
	{
	case QEvent::MouseButtonPress:
	case QEvent::MouseButtonRelease:
	case QEvent::MouseMove:
		{
			QMouseEvent* me = (QMouseEvent*)event;
			bool ok = event->type() == QEvent::MouseMove ? ((me->buttons() & Qt::LeftButton) != 0) : (me->button() == Qt::LeftButton);
			if(ok)
			{
				float x = float(me->x())/width();
				float y = float(me->y())/height();
				OnTouch(x, y, event->type() != QEvent::MouseButtonRelease, 0);
				return true;
			}
		}
		return true;
	case QEvent::TouchBegin:
	case QEvent::TouchUpdate:
	case QEvent::TouchEnd:
		{
			QTouchEvent* te = (QTouchEvent*)event;
			foreach(const QTouchEvent::TouchPoint& p, te->touchPoints())
			{
				float x = p.pos().x()/width();
				float y = p.pos().x()/height();
				OnTouch(x, y, p.state() != Qt::TouchPointReleased, p.id());
			}
		}
		return true;
	default:
		return QWidget::event(event);
	}
}
开发者ID:DarkSlim,项目名称:unrealspeccyp,代码行数:39,代码来源:qt_control.cpp

示例6: switch

bool RSButtonOnText::isEventForThis(QObject *obj, QEvent *event, QPoint &point)
{
	switch (event->type()) {
		case QEvent::MouseButtonPress://2
		case QEvent::MouseButtonRelease://3
		case QEvent::MouseButtonDblClick://4
		case QEvent::MouseMove://5
		{
			QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
			point = mouseEvent->pos();
		}
		break;
		case QEvent::ToolTip://110
		{
			QHelpEvent* helpEvent = static_cast<QHelpEvent*>(event);
			point = helpEvent->globalPos();
		}
		break;
		default:
		return false;
	}

	if (!event->isAccepted()) return false;//Already other take this event (true by default)

	if (obj ==_textEditViewPort) {
		if (_textEdit){

			QTextCursor cursor = _textEdit->cursorForPosition(point);
			if ( (_textCursor->anchor() <= cursor.anchor())
			     && (cursor.position() <= _textCursor->anchor()+_lenght)){
				return true;
			}
		}
	}
	return false;
}
开发者ID:G10h4ck,项目名称:RetroShare,代码行数:36,代码来源:RsButtonOnText.cpp

示例7: resizeLabel

bool CustomerView::eventFilter(QObject* label, QEvent* vt)
{
    if(label==m_ui->m_scrollAreaVisual)
    {
        /*if(vt->type() == QEvent::Resize)
        {
            resizeLabel();
        }*/
    }
    else if((label == m_label)&&
           ((vt->type() == QEvent::MouseButtonPress)||(vt->type() == QEvent::MouseButtonRelease)||(vt->type() == QEvent::MouseMove)))
    {
        QMouseEvent* evt = static_cast<QMouseEvent*>(vt);
        QPoint posOnLabel= evt->pos();


        int w = m_label->geometry().width();
        int h = m_label->geometry().height();

        qreal ratioW =  static_cast<qreal>(m_window->width())/ static_cast<qreal>(w);
        qreal ratioH =  static_cast<qreal>(m_window->height())/static_cast<qreal>(h);

        qreal x = (posOnLabel.x()) * ratioW;
        qreal y = (posOnLabel.y()) * ratioH;

        QPointF posOnQML(x,y);
        QMouseEvent* event = new QMouseEvent(evt->type(),posOnQML.toPoint(),evt->button(),evt->buttons(),evt->modifiers());

        QObject* root = m_engine->rootObjects().first();
        //QCoreApplication::sendEvent(m_window,event);
        QCoreApplication::sendEvent(root,event);
        //m_window->sendEvent(m_window->contentItem(),event);
        return true;
    }
    return false;
}
开发者ID:obiwankennedy,项目名称:rcm,代码行数:36,代码来源:customerview.cpp

示例8: slotMouseReleased

void QwtPlotWidget::slotMouseReleased( const QMouseEvent &e)
{
  double x,y;
  char buf[100];

  int dx = 0;
  int dy = 0;
  QwtScaleWidget *awx = axisWidget(QwtPlot::yLeft);
  if(awx != NULL) dx = awx->width();
  QwtScaleWidget *awy = axisWidget(QwtPlot::xTop);
  if(awy != NULL) dy = awy->height();
  x = this->invTransform(QwtPlot::xBottom, e.pos().x() - dx);
  y = this->invTransform(QwtPlot::yLeft,   e.pos().y() - dy);
  sprintf( buf, "QPlotMouseReleased(%d,%f,%f)\n",id, x, y );
  tcp_send(s,buf,strlen(buf));
}
开发者ID:376473984,项目名称:pvb,代码行数:16,代码来源:qwtplotwidget.cpp

示例9: eventFilter

bool FancyTabProxyStyle::eventFilter(QObject* o, QEvent* e)
{
    QTabBar* bar = qobject_cast<QTabBar*>(o);
    if (bar && (e->type() == QEvent::MouseMove || e->type() == QEvent::Leave)) {
        QMouseEvent* event = static_cast<QMouseEvent*>(e);
        const QString old_hovered_tab = bar->property("tab_hover").toString();
        const QString hovered_tab = e->type() == QEvent::Leave ? QString() : bar->tabText(bar->tabAt(event->pos()));
        bar->setProperty("tab_hover", hovered_tab);

        if (old_hovered_tab != hovered_tab) {
            bar->update();
        }
    }

    return false;
}
开发者ID:Martii,项目名称:qupzilla,代码行数:16,代码来源:fancytabwidget.cpp

示例10: 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;
}
开发者ID:rcari,项目名称:libGooey,代码行数:44,代码来源:GooeyDoubleSpinBox.cpp

示例11: if

bool ptToolBox::eventFilter(QObject* ASender, QEvent* AEvent) {
  if (ASender == FHelpIcon && AEvent->type() == QEvent::MouseButtonRelease) {
    QMouseEvent* e = (QMouseEvent*)AEvent;
    if (e->button() == Qt::LeftButton) {
      QDesktopServices::openUrl(QUrl(FFilter->helpUri()));
      return true;
    } else {
      return false;
    }


  } else if (ASender == FHeaderWidget && AEvent->type() == QEvent::MouseButtonRelease) {
    QMouseEvent* hEvent = (QMouseEvent*)AEvent;
    if (hEvent->button() == Qt::LeftButton && hEvent->modifiers() == Qt::NoModifier) {
      toggleFolded();
      return true;

    } else if (hEvent->button() == Qt::LeftButton && hEvent->modifiers() == Qt::ControlModifier) {
      // toggle block
      createMenuActions();
      FBlockAction->activate(QAction::Trigger);
      return true;

    } else if (hEvent->button() == Qt::RightButton) {
      // context menu
      execContextMenu(hEvent->globalPos());
      return true;

    } else {
      return false;
    }


  } else {
    return QWidget::eventFilter(ASender, AEvent);
  }
}
开发者ID:divyang4481,项目名称:photivo,代码行数:37,代码来源:ptToolBox.cpp

示例12: buffer

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);
}
开发者ID:kingst,项目名称:op2-browser,代码行数:52,代码来源:webpage.cpp

示例13: findPathGraph

bool scissor::eventFilter(QObject *obj, QEvent *event)
{
    if(qobject_cast<QLabel*>(obj)==ui->label &&event->type() == QEvent::MouseButtonPress)
    {
        cout<<"click"<<endl;
        if(Is_start)
        {
            Is_graphed = 0;
            if(!Init_seed)
            {
                seed_vector.clear();
                fullPath_vector.clear();
                shortPath_vector.clear();
                cout<<"init_seed"<<endl;
                Init_seed = 1;
            }
            QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);

            int x = mouseEvent->pos().y();
            int y =mouseEvent->pos().x();
            cout<<"mouse click "<<x<<"  "<<y<<endl;
            if(x < image.rows && y < image.cols)
                if(!Is_closed)
                    findPathGraph(x,y);
                else
                    if(Is_mask)
                        getMask(x,y);
            closeDetect(x,y);

        }
    }
    if (qobject_cast<QLabel*>(obj)==ui->label &&event->type() == QEvent::MouseMove)
    {

        QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);


        statusBar()->showMessage(QString("Mouse move (%1,%2)").arg(mouseEvent->pos().y()).arg(mouseEvent->pos().x()));
        if(Is_graphed == 1)
        {
            int x = mouseEvent->pos().y();
            int y = mouseEvent->pos().x();
            //cout<<"x  "<<x<<"y   "<<y<<endl;
            if(x < image.rows && y < image.cols && !Is_closed)
            {
                moveMouse(x,y);
                cout<<"move mouse"<<x<<"  " <<y <<endl;
            }
        }
    }
    return false;
}
开发者ID:groundmelon,项目名称:intelligent-scissor,代码行数:52,代码来源:scissor.cpp

示例14: QMouseEvent

void EWAUserAction::execute( QWebView *webViewPtr ) const
{
    if( !webViewPtr )
    {
        return;
    }
    
    //EWAWebView *pEwaWebView = qobject_cast<EWAWebView*>( webViewPtr );
    //bool bNeedSetFocus = false;
    QEvent *pEventCopy = 0;
    
    if( isMouseEvent( m_pEvent->type() ) )
    {
        QMouseEvent *pSrcMouseEvent = static_cast<QMouseEvent *>( m_pEvent );
        
        QPoint clickCoords = pSrcMouseEvent->pos();
        
        pEventCopy = new QMouseEvent( 
            pSrcMouseEvent->type(), 
            clickCoords, 
            webViewPtr->mapToGlobal( clickCoords ), 
            pSrcMouseEvent->button(), 
            pSrcMouseEvent->buttons(),
            pSrcMouseEvent->modifiers() );
        
        
    }
    
    else if( isKeyEvent( m_pEvent->type() ) )
    {
        QKeyEvent *pSrcKeyEvent = static_cast<QKeyEvent*>( m_pEvent );
        
        pEventCopy = new QKeyEvent( 
            pSrcKeyEvent->type(), 
            pSrcKeyEvent->key(), 
            pSrcKeyEvent->modifiers(),
            pSrcKeyEvent->text(), 
            pSrcKeyEvent->isAutoRepeat(), 
            pSrcKeyEvent->count() );
    }
     
     if( pEventCopy )
     {
        QSize dstSz = getWebViewSize();
        if( webViewPtr->page()->preferredContentsSize() != dstSz )
        {
            webViewPtr->page()->setPreferredContentsSize( dstSz );
        }
        
        EWAApplication::postEvent( webViewPtr, pEventCopy );
     }
}
开发者ID:sendevent,项目名称:ewa,代码行数:52,代码来源:ewa_useraction.cpp

示例15: switch

bool KDockSplitter::eventFilter(QObject *o, QEvent *e)
{
  QMouseEvent *mev;
  bool handled = false;
  int factor = (mHighResolution)? 10000:100;

  switch (e->type()) {
    case QEvent::MouseMove:
      mev= (QMouseEvent*)e;
      child0->setUpdatesEnabled(mOpaqueResize);
      child1->setUpdatesEnabled(mOpaqueResize);
      if (orientation == Horizontal) {
        if (!mOpaqueResize) {
          int position = checkValue( mapFromGlobal(mev->globalPos()).y() );
          divider->move( 0, position );
        } else {
          xpos = factor * checkValue( mapFromGlobal(mev->globalPos()).y() ) / height();
          resizeEvent(0);
          divider->repaint(true);
        }
      } else {
        if (!mOpaqueResize) {
          int position = checkValue( mapFromGlobal(QCursor::pos()).x() );
          divider->move( position, 0 );
        } else {
          xpos = factor * checkValue( mapFromGlobal( mev->globalPos()).x() ) / width();
          resizeEvent(0);
          divider->repaint(true);
        }
      }
      handled= true;
      break;
    case QEvent::MouseButtonRelease:
      child0->setUpdatesEnabled(true);
      child1->setUpdatesEnabled(true);
      mev= (QMouseEvent*)e;
      if (orientation == Horizontal){
        xpos = factor* checkValue( mapFromGlobal(mev->globalPos()).y() ) / height();
        resizeEvent(0);
        divider->repaint(true);
      } else {
        xpos = factor* checkValue( mapFromGlobal(mev->globalPos()).x() ) / width();
        resizeEvent(0);
        divider->repaint(true);
      }
      handled= true;
      break;
    default:
      break;
  }
  return (handled) ? true : QWidget::eventFilter( o, e );
}
开发者ID:eldarerathis,项目名称:xpertmud,代码行数:52,代码来源:kdockwidget_private.cpp


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