本文整理汇总了C++中QScrollArea::setCursor方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::setCursor方法的具体用法?C++ QScrollArea::setCursor怎么用?C++ QScrollArea::setCursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::setCursor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool MainWindow::eventFilter( QObject * object, QEvent * event )
{
QScrollArea * scrollArea = ui->scrollArea;
if ( object == scrollArea )
{
if ( event->type() == QEvent::MouseButtonPress )
{
QMouseEvent * mouseEvent = static_cast < QMouseEvent * > ( event );
if ( mouseEvent->button() == Qt::LeftButton )
{
lastPos = mouseEvent->pos();
if( scrollArea->horizontalScrollBar()->isVisible() || scrollArea->verticalScrollBar()->isVisible() )
scrollArea->setCursor( Qt::ClosedHandCursor );
else
scrollArea->setCursor( Qt::ArrowCursor );
}
}else if ( event->type() == QEvent::MouseMove )
{
QMouseEvent *mouseEvent = static_cast < QMouseEvent * > ( event );
if ( mouseEvent->buttons() == Qt::LeftButton )
{
lastPos -= mouseEvent->pos();
int hValue = scrollArea->horizontalScrollBar()->value();
int vValue = scrollArea->verticalScrollBar()->value();
scrollArea->horizontalScrollBar()->setValue( lastPos.x() + hValue );
scrollArea->verticalScrollBar()->setValue( lastPos.y() + vValue );
lastPos = mouseEvent->pos();
}
}else if ( event->type() == QEvent::MouseButtonRelease )
scrollArea->setCursor( Qt::ArrowCursor );
}
return QWidget::eventFilter(object, event);
}