本文整理汇总了C++中QScrollBar::triggerAction方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar::triggerAction方法的具体用法?C++ QScrollBar::triggerAction怎么用?C++ QScrollBar::triggerAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollBar
的用法示例。
在下文中一共展示了QScrollBar::triggerAction方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyPressEvent
void NHelpDialog::keyPressEvent(QKeyEvent *event)
{
switch (event->key( ))
{
case Qt::Key_PageUp:
case Qt::Key_PageDown:
{
QScrollBar *vbar = textScrollArea->verticalScrollBar( );
if (vbar)
{
switch (event->key())
{
case Qt::Key_PageUp:
vbar->triggerAction(QAbstractSlider::SliderPageStepSub);
break;
case Qt::Key_PageDown:
vbar->triggerAction(QAbstractSlider::SliderPageStepAdd);
break;
}
}
}
break;
case Qt::Key_HomePage:
case Qt::Key_Escape:
case Qt::Key_Left:
case Qt::Key_Help:
case Qt::Key_Enter:
case Qt::Key_MediaRecord:
case Qt::Key_MediaPlay:
this->close( );
break;
default:
break;
}
}
示例2: keyPressEvent
void MainWindow::keyPressEvent(QKeyEvent *e)
{
if (e->key() == Qt::Key_Up)
{
// meh.. try faking it
QScrollBar *vscroll = ui->graphicsView->verticalScrollBar();
vscroll->triggerAction(QScrollBar::SliderSingleStepSub);
// scrolls entire widget (not just viewport)
//ui->graphicsView->scroll(0, 10);
//scroll(0, 10);
// not necessary: starts as accepted
//e->accept();
return;
}
else if (e->key() == Qt::Key_Down)
{
// meh.. try faking it
QScrollBar *vscroll = ui->graphicsView->verticalScrollBar();
vscroll->triggerAction(QScrollBar::SliderSingleStepAdd);
// ok, this gives us both current scaling
// and current translation (scrolled position)
// of the view
//QTransform vptr = ui->graphicsView->viewportTransform();
// translate() seems to want absolute coordinates
// instead of relative delta??
//ui->graphicsView->translate(0, 100);
// scrolls entire widget (not just viewport)
//ui->graphicsView->scroll(0, -10);
//scroll(0, -10);
// drawing isn't correct but at least affects actual image..
//ui->graphicsView->viewport()->scroll(0, -10);
return;
}
// pass to base-class
QMainWindow::keyPressEvent(e);
}