本文整理汇总了C++中MarbleWidget::setCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ MarbleWidget::setCursor方法的具体用法?C++ MarbleWidget::setCursor怎么用?C++ MarbleWidget::setCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarbleWidget
的用法示例。
在下文中一共展示了MarbleWidget::setCursor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: eventFilter
bool License::eventFilter( QObject *object, QEvent *event )
{
if ( !enabled() || !visible() )
return false;
MarbleWidget *widget = dynamic_cast<MarbleWidget*>( object );
if ( !widget ) {
return AbstractFloatItem::eventFilter( object,event );
}
if( event->type() == QEvent::MouseMove ) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>( event );
QRectF floatItemRect = QRectF( positivePosition(), size() );
if ( floatItemRect.contains( mouseEvent->pos() ) ) {
widget->setCursor( QCursor( Qt::ArrowCursor ) );
return true;
}
}
return AbstractFloatItem::eventFilter( object, event );
}
示例3: eventFilter
//.........这里部分代码省略.........
if ( e->type() == QEvent::MouseMove ) {
return false;
}
// Move ScreenGraphicsItem
if ( e->type() == QEvent::MouseButtonPress )
{
QMouseEvent *event = static_cast<QMouseEvent*>(e);
// Click and move above a float item triggers moving the float item
if ( contains( event->pos() ) ) {
if ( event->button() == Qt::LeftButton ) {
p()->m_floatItemMoveStartPos = event->pos();
p()->m_floatItemMoving = true;
return true;
}
}
}
return false;
}
else {
// Move ScreenGraphicsItem
bool cursorAboveFloatItem = false;
if ( e->type() == QEvent::MouseMove
|| e->type() == QEvent::MouseButtonPress
|| e->type() == QEvent::MouseButtonRelease )
{
QMouseEvent *event = static_cast<QMouseEvent*>( e );
// The rect the item was painted on before. We add one pixel as antialiasing could
// result into painting on these pixels to.
QRectF floatItemRect = QRectF( positivePosition() - QPoint( 1, 1 ),
size() + QSize( 2, 2 ) );
// Click and move above a float item triggers moving the float item
if ( contains( event->pos() ) ) {
cursorAboveFloatItem = true;
if ( e->type() == QEvent::MouseButtonPress && event->button() == Qt::LeftButton ) {
p()->m_floatItemMoveStartPos = event->pos();
return true;
}
}
if ( e->type() == QEvent::MouseMove && event->buttons() & Qt::LeftButton && p()->isMovable() )
{
p()->m_floatItemMoving = true;
const QPoint &point = event->pos();
QPointF position = positivePosition();
qreal newX = position.x()+point.x()-p()->m_floatItemMoveStartPos.x();
qreal newY = position.y()+point.y()-p()->m_floatItemMoveStartPos.y();
if ( newX >= 0 && newY >= 0 ) {
// docking behavior
const qreal dockArea = 60.0; // Alignment area width/height
const qreal dockJump = 30.0; // Alignment indicator jump size
if ( widget->width()-size().width()-newX < dockArea ) {
newX = qMin( qreal( -1.0 ), size().width() + newX-widget->width() );
if ( p()->m_floatItemMoveStartPos.x() < event->pos().x() ) {
// Indicate change to right alignment with a short jump
newX = qMax( newX, -(dockArea-dockJump) );
}
}
if ( widget->height()-size().height()-newY < dockArea ) {
newY = qMin( qreal( -1.0 ), size().height() + newY-widget->height() );
if (p()->m_floatItemMoveStartPos.y()<event->pos().y()) {
// Indicate change to bottom alignment with a short jump
newY = qMax( newY, -( dockArea - dockJump ) );
}
}
setPosition( QPointF( newX,newY ) );
// The rect the item will be painted on now. We add one pixel as
// antialiasing could result into painting on these pixels to.
QRect newFloatItemRect = QRectF( positivePosition() - QPoint( 1, 1 ),
size() + QSize( 2, 2 ) ).toRect();
p()->m_floatItemMoveStartPos = event->pos();
QRegion dirtyRegion( floatItemRect.toRect() );
dirtyRegion = dirtyRegion.united( newFloatItemRect );
widget->setAttribute( Qt::WA_NoSystemBackground, false );
widget->update(dirtyRegion);
widget->setAttribute( Qt::WA_NoSystemBackground, widget->viewport()->mapCoversViewport() );
return true;
}
}
if ( e->type() == QEvent::MouseButtonRelease ) {
p()->m_floatItemMoving = false;
}
// Adjusting Cursor shape
if ( cursorAboveFloatItem || p()->m_floatItemMoving ) {
widget->setCursor(QCursor(Qt::SizeAllCursor));
return true;
}
}
return MarbleGraphicsItem::eventFilter( object, e );
}
}
示例4: eventFilter
bool ElevationProfileFloatItem::eventFilter( QObject *object, QEvent *e )
{
if ( !enabled() || !visible() ) {
return false;
}
MarbleWidget *widget = dynamic_cast<MarbleWidget*>( object );
if ( !widget ) {
return AbstractFloatItem::eventFilter(object,e);
}
if ( widget && !m_marbleWidget ) {
m_marbleWidget = widget;
connect( this, SIGNAL(dataUpdated()), this, SLOT(updateVisiblePoints()) );
connect( m_marbleWidget, SIGNAL(visibleLatLonAltBoxChanged(GeoDataLatLonAltBox)),
this, SLOT(updateVisiblePoints()) );
connect( this, SIGNAL(settingsChanged(QString)), this, SLOT(updateVisiblePoints()) );
}
if ( e->type() == QEvent::MouseButtonDblClick || e->type() == QEvent::MouseMove ) {
GeoDataTreeModel *const treeModel = const_cast<MarbleModel *>( marbleModel() )->treeModel();
QMouseEvent *event = static_cast<QMouseEvent*>( e );
QRectF plotRect = QRectF ( m_leftGraphMargin, 0, m_eleGraphWidth, contentSize().height() );
plotRect.translate( positivePosition() );
plotRect.translate( padding(), padding() );
// for antialiasing: increase size by 1 px to each side
plotRect.translate(-1, -1);
plotRect.setSize(plotRect.size() + QSize(2, 2) );
const bool cursorAboveFloatItem = plotRect.contains(event->pos());
if ( cursorAboveFloatItem ) {
const int start = m_zoomToViewport ? m_firstVisiblePoint : 0;
const int end = m_zoomToViewport ? m_lastVisiblePoint : m_eleData.size();
// Double click triggers recentering the map at the specified position
if ( e->type() == QEvent::MouseButtonDblClick ) {
const QPointF mousePosition = event->pos() - plotRect.topLeft();
const int xPos = mousePosition.x();
for ( int i = start; i < end; ++i) {
const int plotPos = ( m_eleData.value(i).x() - m_axisX.minValue() ) * m_eleGraphWidth / m_axisX.range();
if ( plotPos >= xPos ) {
widget->centerOn( m_points[i], true );
break;
}
}
return true;
}
if ( e->type() == QEvent::MouseMove && !(event->buttons() & Qt::LeftButton) ) {
// Cross hair cursor when moving above the float item
// and mark the position on the graph
widget->setCursor(QCursor(Qt::CrossCursor));
if ( m_cursorPositionX != event->pos().x() - plotRect.left() ) {
m_cursorPositionX = event->pos().x() - plotRect.left();
const qreal xpos = m_axisX.minValue() + ( m_cursorPositionX / m_eleGraphWidth ) * m_axisX.range();
GeoDataCoordinates currentPoint; // invalid coordinates
for ( int i = start; i < end; ++i) {
if ( m_eleData.value(i).x() >= xpos ) {
currentPoint = m_points[i];
currentPoint.setAltitude( m_eleData.value(i).y() );
break;
}
}
m_markerPlacemark->setCoordinate( currentPoint );
if ( m_documentIndex < 0 ) {
m_documentIndex = treeModel->addDocument( &m_markerDocument );
}
emit repaintNeeded();
}
return true;
}
}
else {
if ( m_documentIndex >= 0 ) {
m_markerPlacemark->setCoordinate( GeoDataCoordinates() ); // set to invalid
treeModel->removeDocument( &m_markerDocument );
m_documentIndex = -1;
emit repaintNeeded();
}
}
}
return AbstractFloatItem::eventFilter(object,e);
}