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


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

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


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

示例1: mouseReleaseEvent

bool PicItem::mouseReleaseEvent( const EventInfo &info )
{
	QMouseEvent *e = info.mouseReleaseEvent( 0, 0 );
	if ( !m_pressed ) {
		delete e;
		return CNItem::mouseReleaseEvent( info );
	}

	const PinItemList::iterator end = m_pinItemList.end();
	for ( PinItemList::iterator it = m_pinItemList.begin(); it != end; ++it )
		if ( !e->isAccepted() ) {
			continue;
		} else if ( (*it)->boundingRect().contains(m_pos) && (*it)->boundingRect().contains( info.pos ) ) {
			if ( m_dragged ) {
				(*it)->dragged( m_dx );
			} else {
				(*it)->switchState();
			}
			m_pressed = false;
			m_dragged = false;
			m_pos = QPoint();
			m_dx = 0;
			delete e;
			return true;
		}
	delete e;
	return CNItem::mouseReleaseEvent( info );
}
开发者ID:ktechlab,项目名称:ktechlab-0.3,代码行数:28,代码来源:picitem.cpp

示例2: QMouseEvent

RMouseEvent::RMouseEvent(const QMouseEvent& mouseEvent, RGraphicsScene& s,
        RGraphicsView& v, qreal devicePixelRatio) :
    QMouseEvent(mouseEvent),
    RInputEvent(RVector(mouseEvent.posF().x(), mouseEvent.posF().y()), s, v, devicePixelRatio) {

    setAccepted(mouseEvent.isAccepted());
}
开发者ID:ppiecuch,项目名称:qcad,代码行数:7,代码来源:RMouseEvent.cpp

示例3: mouseReleaseEvent

void CurveEditorItem::mouseReleaseEvent(QMouseEvent* event)
{
    QMouseEvent* mouseEvent = new QMouseEvent(event->type(), event->pos(), event->button(), event->buttons(), event->modifiers());
    d->curveWidget->mouseReleaseEvent(mouseEvent);
    if(mouseEvent->isAccepted()) {
        event->accept();
    }
    d->repaint();
}
开发者ID:AninaRJ,项目名称:krita,代码行数:9,代码来源:CurveEditorItem.cpp

示例4: mousePressEvent

void CurveEditorItem::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
    QMouseEvent* mouseEvent = new QMouseEvent(event->type(), event->pos().toPoint(), event->button(), event->buttons(), event->modifiers());
    d->curveWidget->mousePressEvent(mouseEvent);
    if(mouseEvent->isAccepted()) {
        event->accept();
    }
    d->repaint();
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:9,代码来源:CurveEditorItem.cpp

示例5: mouseMoveEvent

bool PicItem::mouseMoveEvent( const EventInfo &info )
{
	QMouseEvent *e = info.mouseMoveEvent( 0, 0 );
	const PinItemList::iterator end = m_pinItemList.end();
	for ( PinItemList::iterator it = m_pinItemList.begin(); it != end; ++it )
		if ( e->isAccepted() && (*it)->boundingRect().contains( info.pos ) ) {
			QPoint vec = info.pos - m_pos;
			if ( m_pressed && vec.manhattanLength() > 4 ) {
				m_dragged = true;
				m_dx = vec.x();
        		}
			delete e;
			return true;
		}
	delete e;
	return CNItem::mouseMoveEvent( info );
}
开发者ID:ktechlab,项目名称:ktechlab-0.3,代码行数:17,代码来源:picitem.cpp

示例6: mousePressEvent

bool PicItem::mousePressEvent( const EventInfo &info )
{
	QMouseEvent *e = info.mousePressEvent( 0, 0 );
	const PinItemList::iterator end = m_pinItemList.end();
	for ( PinItemList::iterator it = m_pinItemList.begin(); it != end; ++it )
		if ( e->isAccepted() && (*it)->boundingRect().contains( info.pos ) ) {
			//reset mouse-gesture state
			m_pressed = true;
			m_pos = info.pos;
			m_dragged = false;
			m_dx = 0;
			delete e;
			return true;
		}

	m_pressed = false;
	delete e;
	return CNItem::mousePressEvent( info );
}
开发者ID:ktechlab,项目名称:ktechlab-0.3,代码行数:19,代码来源:picitem.cpp

示例7: sendWidgetMouseEvent

/*!
    \internal
*/
void QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent(QGraphicsSceneMouseEvent *event)
{
    if (!event || !widget || !widget->isVisible())
        return;
    Q_Q(QGraphicsProxyWidget);

    // Find widget position and receiver.
    QPointF pos = event->pos();
    QPointer<QWidget> alienWidget = widget->childAt(pos.toPoint());
    QPointer<QWidget> receiver =  alienWidget ? alienWidget : widget;

    if (QWidgetPrivate::nearestGraphicsProxyWidget(receiver) != q)
        return; //another proxywidget will handle the events

    // Translate QGraphicsSceneMouse events to QMouseEvents.
    QEvent::Type type = QEvent::None;
    switch (event->type()) {
    case QEvent::GraphicsSceneMousePress:
        type = QEvent::MouseButtonPress;
        if (!embeddedMouseGrabber)
            embeddedMouseGrabber = receiver;
        else
            receiver = embeddedMouseGrabber;
        break;
    case QEvent::GraphicsSceneMouseRelease:
        type = QEvent::MouseButtonRelease;
        if (embeddedMouseGrabber)
            receiver = embeddedMouseGrabber;
        break;
    case QEvent::GraphicsSceneMouseDoubleClick:
        type = QEvent::MouseButtonDblClick;
        if (!embeddedMouseGrabber)
            embeddedMouseGrabber = receiver;
        else
            receiver = embeddedMouseGrabber;
        break;
    case QEvent::GraphicsSceneMouseMove:
        type = QEvent::MouseMove;
        if (embeddedMouseGrabber)
            receiver = embeddedMouseGrabber;
        break;
    default:
        Q_ASSERT_X(false, "QGraphicsProxyWidget", "internal error");
        break;
    }

    if (!lastWidgetUnderMouse) {
        QApplicationPrivate::dispatchEnterLeave(embeddedMouseGrabber ? embeddedMouseGrabber : widget, 0);
        lastWidgetUnderMouse = widget;
    }

    // Map event position from us to the receiver
    pos = mapToReceiver(pos, receiver);

    // Send mouse event.
    QMouseEvent *mouseEvent = QMouseEvent::createExtendedMouseEvent(type, pos,
                                                                    receiver->mapToGlobal(pos.toPoint()), event->button(),
                                                                    event->buttons(), event->modifiers());

    QWidget *embeddedMouseGrabberPtr = (QWidget *)embeddedMouseGrabber;
    QApplicationPrivate::sendMouseEvent(receiver, mouseEvent, alienWidget, widget,
                                        &embeddedMouseGrabberPtr, lastWidgetUnderMouse, event->spontaneous());
    embeddedMouseGrabber = embeddedMouseGrabberPtr;

    // Handle enter/leave events when last button is released from mouse
    // grabber child widget.
    if (embeddedMouseGrabber && type == QEvent::MouseButtonRelease && !event->buttons()) {
        Q_Q(QGraphicsProxyWidget);
        if (q->rect().contains(event->pos()) && q->acceptsHoverEvents())
            lastWidgetUnderMouse = alienWidget ? alienWidget : widget;
        else // released on the frame our outside the item, or doesn't accept hover events.
            lastWidgetUnderMouse = 0;

        QApplicationPrivate::dispatchEnterLeave(lastWidgetUnderMouse, embeddedMouseGrabber);
        embeddedMouseGrabber = 0;

#ifndef QT_NO_CURSOR
        // ### Restore the cursor, don't override it.
        if (!lastWidgetUnderMouse)
            q->unsetCursor();
#endif
    }

    event->setAccepted(mouseEvent->isAccepted());
    delete mouseEvent;
}
开发者ID:Nacto1,项目名称:qt-everywhere-opensource-src-4.6.2,代码行数:89,代码来源:qgraphicsproxywidget.cpp


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