本文整理汇总了C++中QScrollBar::pageStep方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar::pageStep方法的具体用法?C++ QScrollBar::pageStep怎么用?C++ QScrollBar::pageStep使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollBar
的用法示例。
在下文中一共展示了QScrollBar::pageStep方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: eventFilter
bool RecentBooksDlg::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
QString text;
switch(keyEvent->key()) {
case Qt::Key_Up:
if(obj == m_ui->tableWidget) {
QScrollBar * scrollBar = m_ui->tableWidget->verticalScrollBar();
int pageStrCount = scrollBar->pageStep();
int fullStrCount = scrollBar->maximum()-scrollBar->minimum()+pageStrCount;
if(fullStrCount==pageStrCount) {
pageCount = 1;
//return;
}
if(pageStrCount==1) {
scrollBar->setMaximum(fullStrCount*2);
pageStrCount = scrollBar->pageStep();
}
pageCount = ceil((double)fullStrCount/pageStrCount);
if(((m_ui->tableWidget->currentRow()+1)/2 == 1) && (pageStrCount/2>1)){
}
}
break;
return true;
}
}
return false;
}
示例2: tr
void
Viewer::scaleImage()
{
std::stringstream msg;
if (!graphView) {
msg << "No image to scale";
}
else {
// scale image by amount on slider
double factor = (100.0 - this->ui.horizontalSlider->value()) / 100.0;
graphView->resize(factor * graphView->pixmap()->size());
QScrollBar* scrollBar = this->ui.scrollArea->horizontalScrollBar();
scrollBar->setValue(int(factor * scrollBar->value()
+ ((factor - 1) * scrollBar->pageStep()/2)));
scrollBar = this->ui.scrollArea->verticalScrollBar();
scrollBar->setValue(int(factor * scrollBar->value()
+ ((factor - 1) * scrollBar->pageStep()/2)));
this->ui.scrollArea->setBackgroundRole(QPalette::Dark);
this->ui.scrollArea->setWidget(graphView);
this->ui.scrollArea->show();
msg << "Image scaled to " << factor;
}
this->ui.statusbar->showMessage( tr(msg.str().c_str()));
}
示例3: zoomInOut
void Viewer::zoomInOut(const double f)
{
_scale *= f;
_image->resize(_scale * _image->pixmap()->size());
QScrollBar *hbar = horizontalScrollBar();
QScrollBar *vbar = verticalScrollBar();
int hs = int(f * hbar->value() + ((f - 1) * hbar->pageStep() / 2));
int vs = int(f * vbar->value() + ((f - 1) * vbar->pageStep() / 2));
hbar->setValue(hs);
vbar->setValue(vs);
}
示例4: zoomInOut
void ImageViewerWidget::zoomInOut(const double f)
{
m_Scale *= f;
m_Image->resize(m_Scale * m_Image->pixmap()->size());
QScrollBar *hbar = horizontalScrollBar();
QScrollBar *vbar = verticalScrollBar();
int hs = int(f * hbar->value() + ((f - 1) * hbar->pageStep() / 2));
int vs = int(f * vbar->value() + ((f - 1) * vbar->pageStep() / 2));
hbar->setValue(hs);
vbar->setValue(vs);
}
示例5: eventFilter
bool ChatWindow::eventFilter(QObject* watched, QEvent* e)
{
if(e->type() == QEvent::KeyPress)
{
QKeyEvent* ke = static_cast<QKeyEvent*>(e);
bool scrollMod = (Preferences::self()->useMultiRowInputBox() ? false : (ke->modifiers() == Qt::ShiftModifier));
if(ke->key() == Qt::Key_Up && scrollMod)
{
if(textView)
{
QScrollBar* sbar = textView->verticalScrollBar();
sbar->setValue(sbar->value() - sbar->singleStep());
}
return true;
}
else if(ke->key() == Qt::Key_Down && scrollMod)
{
if(textView)
{
QScrollBar* sbar = textView->verticalScrollBar();
sbar->setValue(sbar->value() + sbar->singleStep());
}
return true;
}
else if(ke->modifiers() == Qt::NoModifier && ke->key() == Qt::Key_PageUp)
{
if(textView)
{
QScrollBar* sbar = textView->verticalScrollBar();
sbar->setValue(sbar->value() - sbar->pageStep());
}
return true;
}
else if(ke->modifiers() == Qt::NoModifier && ke->key() == Qt::Key_PageDown)
{
if(textView)
{
QScrollBar* sbar = textView->verticalScrollBar();
sbar->setValue(sbar->value() + sbar->pageStep());
}
return true;
}
}
return QWidget::eventFilter(watched, e);
}
示例6: genericVScroll
void EmacsKeysPlugin::genericVScroll(int direction)
{
if (!m_currentEditorWidget)
return;
m_currentState->beginOwnAction();
QScrollBar *verticalScrollBar = m_currentEditorWidget->verticalScrollBar();
const int value = verticalScrollBar->value();
const int halfPageStep = verticalScrollBar->pageStep() / 2;
const int newValue = value + (direction > 0 ? halfPageStep : -halfPageStep);
verticalScrollBar->setValue(newValue);
// adjust cursor if it's out of screen
const QRect viewportRect = m_currentEditorWidget->viewport()->rect();
const QTextCursor::MoveMode mode =
m_currentState->mark() != -1 ?
QTextCursor::KeepAnchor :
QTextCursor::MoveAnchor ;
const QTextCursor::MoveOperation op =
m_currentEditorWidget->cursorRect().y() < 0 ?
QTextCursor::Down :
QTextCursor::Up ;
QTextCursor cursor = m_currentEditorWidget->textCursor();
while (!m_currentEditorWidget->cursorRect(cursor).intersects(viewportRect)) {
const int previousPosition = cursor.position();
cursor.movePosition(op, mode);
if (previousPosition == cursor.position())
break;
}
m_currentEditorWidget->setTextCursor(cursor);
m_currentState->endOwnAction(KeysActionOther);
}
示例7: replaceScrollBar
/*! \internal
*/
void QAbstractScrollAreaPrivate::replaceScrollBar(QScrollBar *scrollBar,
Qt::Orientation orientation)
{
Q_Q(QAbstractScrollArea);
QAbstractScrollAreaScrollBarContainer *container = scrollBarContainers[orientation];
bool horizontal = (orientation == Qt::Horizontal);
QScrollBar *oldBar = horizontal ? hbar : vbar;
if (horizontal)
hbar = scrollBar;
else
vbar = scrollBar;
scrollBar->setParent(container);
container->scrollBar = scrollBar;
container->layout->removeWidget(oldBar);
container->layout->insertWidget(0, scrollBar);
scrollBar->setVisible(oldBar->isVisibleTo(container));
scrollBar->setInvertedAppearance(oldBar->invertedAppearance());
scrollBar->setInvertedControls(oldBar->invertedControls());
scrollBar->setRange(oldBar->minimum(), oldBar->maximum());
scrollBar->setOrientation(oldBar->orientation());
scrollBar->setPageStep(oldBar->pageStep());
scrollBar->setSingleStep(oldBar->singleStep());
scrollBar->setSliderDown(oldBar->isSliderDown());
scrollBar->setSliderPosition(oldBar->sliderPosition());
scrollBar->setTracking(oldBar->hasTracking());
scrollBar->setValue(oldBar->value());
delete oldBar;
QObject::connect(scrollBar, SIGNAL(valueChanged(int)),
q, horizontal ? SLOT(_q_hslide(int)) : SLOT(_q_vslide(int)));
QObject::connect(scrollBar, SIGNAL(rangeChanged(int,int)),
q, SLOT(_q_showOrHideScrollBars()), Qt::QueuedConnection);
}
示例8: verticalScrollBar
void
message_view::page_down()
{
QScrollBar* bar = verticalScrollBar();
if (bar) {
bar->setValue(bar->value()+bar->pageStep());
}
}
示例9: fillOpts
void TocDlg::fillOpts()
{
QScrollBar * scrollBar = m_ui->treeWidget->verticalScrollBar();
pageStrCount = scrollBar->pageStep();
fullStrCount = scrollBar->maximum()-scrollBar->minimum()+pageStrCount;
if(fullStrCount==pageStrCount) {
pageCount = 1;
return;
}
if(pageStrCount==1) {
scrollBar->setMaximum(fullStrCount*2);
pageStrCount = scrollBar->pageStep();
}
pageCount = ceil((double)fullStrCount/pageStrCount);
}
示例10: scrollBack
void ManuallyTaggerWindow::scrollBack() {
QScrollBar * vert = ui->scrollArea->verticalScrollBar();
QScrollBar * horz = ui->scrollArea->horizontalScrollBar();
int last_horz = horz->value() - horz->pageStep() / 2;
int last_vert = vert->value() - static_cast<int>(vert->pageStep() * 0.8);
if(horz->value() == horz->minimum() && vert->value() == vert->minimum()) {
back();
} else if(horz->value() == horz->minimum()) {
horz->setValue(horz->maximum());
if(last_vert < vert->minimum()) {
vert->setValue(vert->minimum());
} else {
vert->setValue(last_vert);
}
} else if(last_horz < horz->minimum()) {
horz->setValue(horz->minimum());
} else {
horz->setValue(last_horz);
}
}
示例11: scroll
void ManuallyTaggerWindow::scroll() {
QScrollBar * vert = ui->scrollArea->verticalScrollBar();
QScrollBar * horz = ui->scrollArea->horizontalScrollBar();
int next_horz = horz->value() + horz->pageStep() / 2;
int next_vert = vert->value() + static_cast<int>(vert->pageStep() * 0.8);
if(horz->value() == horz->maximum() && vert->value() == vert->maximum()) {
next();
} else if(horz->value() == horz->maximum()) {
horz->setValue(0);
if(next_vert > vert->maximum()) {
vert->setValue(vert->maximum());
} else {
vert->setValue(next_vert);
}
} else if(next_horz > horz->maximum()) {
horz->setValue(horz->maximum());
} else {
horz->setValue(next_horz);
}
}
示例12: slotAdjustZoom
void ClockPhotoDialog::slotAdjustZoom(int percentage)
{
// Callback for when the zoom slider is adjusted. Scale the image to the new
// value and adjust the scrollbars adjusted so that the center of the
// display remains the same.
// Remember what the old width was.
float oldWidth = d->scrollArea->widget()->width();
// Convert the percentage to an absolute scale and scale the image.
float absScale = (float)percentage / 100;
d->imageLabel->resize(d->image->size() * absScale);
// Calculate the size increase.
float relScale = d->scrollArea->widget()->width() / oldWidth;
// Adjust the scrollbars to the size increase.
QScrollBar *barX = d->scrollArea->horizontalScrollBar();
QScrollBar *barY = d->scrollArea->verticalScrollBar();
barX->setValue(int(relScale * barX->value() + ((relScale - 1) * barX->pageStep()/2)));
barY->setValue(int(relScale * barY->value() + ((relScale - 1) * barY->pageStep()/2)));
}
示例13: QGraphicsProxyWidget
TabsView::TabsView( QGraphicsWidget *parent )
: QGraphicsProxyWidget( parent )
{
// tree view which holds the collection of fetched tabs
m_treeView = new TabsTreeView( 0 );
connect( m_treeView, SIGNAL( clicked( const QModelIndex & ) ),
this, SLOT( itemClicked( const QModelIndex & ) ) );
m_model = new QStandardItemModel();
m_model->setColumnCount( 1 );
m_treeView->setModel( m_model );
m_treeProxy = new QGraphicsProxyWidget( this );
m_treeProxy->setWidget( m_treeView );
// the textbrowser widget to display the tabs
m_tabTextBrowser = new Plasma::TextBrowser( );
KTextBrowser *browserWidget = m_tabTextBrowser->nativeWidget();
browserWidget->setFrameShape( QFrame::StyledPanel );
browserWidget->setAttribute( Qt::WA_NoSystemBackground );
browserWidget->setOpenExternalLinks( true );
browserWidget->setUndoRedoEnabled( true );
browserWidget->setAutoFillBackground( false );
browserWidget->setWordWrapMode( QTextOption::NoWrap );
browserWidget->viewport()->setAutoFillBackground( true );
browserWidget->viewport()->setAttribute( Qt::WA_NoSystemBackground );
browserWidget->setTextInteractionFlags( Qt::TextBrowserInteraction | Qt::TextSelectableByKeyboard );
QScrollBar *treeScrollBar = m_treeView->verticalScrollBar();
m_scrollBar = new Plasma::ScrollBar( this );
m_scrollBar->setFocusPolicy( Qt::NoFocus );
// synchronize scrollbars
connect( treeScrollBar, SIGNAL( rangeChanged( int, int ) ), SLOT( slotScrollBarRangeChanged( int, int ) ) );
connect( treeScrollBar, SIGNAL( valueChanged( int ) ), m_scrollBar, SLOT( setValue( int ) ) );
connect( m_scrollBar, SIGNAL( valueChanged( int ) ), treeScrollBar, SLOT( setValue( int ) ) );
m_scrollBar->setRange( treeScrollBar->minimum(), treeScrollBar->maximum() );
m_scrollBar->setPageStep( treeScrollBar->pageStep() );
m_scrollBar->setSingleStep( treeScrollBar->singleStep() );
// arrange textbrowser and treeview in a horizontal layout
QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Horizontal );
layout->addItem( m_treeProxy );
layout->addItem( m_scrollBar );
layout->addItem( m_tabTextBrowser );
layout->setSpacing( 2 );
layout->setContentsMargins( 0, 0, 0, 0 );
setLayout( layout );
setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
updateScrollBarVisibility();
}
示例14: getCurrentItemPage
// code added 28.11.2011
int TocDlg::getCurrentItemPage()
{
if(isPageUpdated) {
on_actionUpdatePage_triggered();
isPageUpdated = false;
}
QScrollBar * scrollBar = m_ui->treeWidget->verticalScrollBar();
pageStrCount = scrollBar->pageStep();
int page_num = 1;
int iCurrentItemPos = getCurrentItemPosFromBegin(m_docview->getToc(),m_ui->treeWidget->currentItem(), 0);
if(iCurrentItemPos>pageStrCount)
page_num = ceil((double)iCurrentItemPos/pageStrCount);
return page_num;
}
示例15: setDrawOffsetInternal
void EditorWidgetBase::setDrawOffsetInternal(VSQ_NS::tick_t drawOffset) {
static QMutex mutex;
if (mutex.tryLock()) {
int xScrollTo = -controllerAdapter->getXFromTick(drawOffset);
QScrollBar *scrollBar = ui->mainContent->horizontalScrollBar();
int maxValue = scrollBar->maximum() + scrollBar->pageStep();
int minValue = scrollBar->minimum();
int contentWidth = static_cast<int>(ui->mainContent->getSceneWidth());
int value = static_cast<int>(minValue
+ (minValue - maxValue) * static_cast<double>(xScrollTo) / contentWidth);
if (scrollBar->value() != value) scrollBar->setValue(value);
mutex.unlock();
}
}