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


C++ QScrollBar::value方法代码示例

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


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

示例1: insertPlainText

void QScrollDownTextBrowser::insertPlainText(const QString &text)
{
    QScrollBar * b = verticalScrollBar();
    if (linecount >= 2000 && autoClear) {
        keepLines(1000);
        moveCursor(QTextCursor::End);
        linecount = 1000;
        QTextBrowser::insertPlainText(text);
        b->setValue(b->maximum());
        return;
    }

    int f = b->value();
    int e = b->maximum();

    moveCursor(QTextCursor::End);
    QTextBrowser::insertPlainText(text);

    if(b->value() != e)
    {
        b->setValue(f);
    }
    else
    {
        b->setValue(b->maximum());
        moveCursor(QTextCursor::End);
    }
    linecount++;
}
开发者ID:Antar1011,项目名称:pokemon-online-1.0.53,代码行数:29,代码来源:otherwidgets.cpp

示例2: verticalScrollBar

void Robot25DWindow::mouseMoveEvent(QMouseEvent *event)
{
    QScrollBar * vert = verticalScrollBar();
    QScrollBar * horiz = horizontalScrollBar();
    bool scrollable = vert->maximum() + horiz->maximum() > 0;
    if (scrollable) {
        if (mousePressPosition_ != QPoint(-1, -1)) {
            setCursor(Qt::ClosedHandCursor);
            const QPoint diff = event->pos() - mousePressPosition_;
            const int dx = diff.x();
            const int dy = diff.y();
            if (dx != 0) {
                horiz->setValue(horiz->value() - dx);
            }
            if (dy != 0) {
                vert->setValue(vert->value() - dy);
            }
            mousePressPosition_ = event->pos();
        }
        event->accept();
    }
    else {
        setCursor(Qt::ArrowCursor);
        event->ignore();
    }
}
开发者ID:woronin,项目名称:kumir2,代码行数:26,代码来源:robot25dwindow.cpp

示例3: 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()));

}
开发者ID:AndroidDev77,项目名称:OpenDDS,代码行数:35,代码来源:Viewer.cpp

示例4: html

void    Chat::insertMessage(const QString& alias,
                            const QString& msg,
                            const QColor& color)
{
  Q_ASSERT(this->_options);

  int           scrollBarValue = -1;
  QScrollBar*   scrollBar = this->outputTextBrowser->verticalScrollBar();

  if (scrollBar && scrollBar->value() != scrollBar->maximum())
    scrollBarValue = scrollBar->value();
  QString html("<p>");
  html += QString("<span style='color:%1;'>%2 %3</span>").arg(color.name()).arg(getFormatedDateTime()).arg(alias);
  html.append(": </p>");
  this->outputTextBrowser->moveCursor(QTextCursor::End);
  this->outputTextBrowser->insertHtml(html);
  replaceUrls(msg);
  this->outputTextBrowser->insertHtml("<br />");
  if (this->_options->chatWidget->smileys())
    insertSmileys();
  if (scrollBar)
    {
      if (scrollBarValue != -1)
        scrollBar->setValue(scrollBarValue);
      else
        scrollBar->setValue(scrollBar->maximum());
    }
}
开发者ID:8102,项目名称:QNetSoul,代码行数:28,代码来源:Chat.cpp

示例5: scrollByDelta

void PageViewBase::scrollByDelta(int dx, int dy)
{
	QScrollBar *vbar = verticalScrollBar();
	QScrollBar *hbar = horizontalScrollBar();

	vbar->setValue(vbar->value() + dy);
	hbar->setValue(hbar->value() + dx);
}
开发者ID:machekku,项目名称:QComicBook,代码行数:8,代码来源:PageViewBase.cpp

示例6: write

void ConsoleWindow::write(QString data, MessageLevel::Enum mode)
{
	QScrollBar *bar = ui->text->verticalScrollBar();
	int max_bar = bar->maximum();
	int val_bar = bar->value();
	if(isVisible())
	{
		if (m_scroll_active)
		{
			m_scroll_active = (max_bar - val_bar) <= 1;
		}
		else
		{
			m_scroll_active = val_bar == max_bar;
		}
	}
	if (data.endsWith('\n'))
		data = data.left(data.length() - 1);
	QStringList paragraphs = data.split('\n');
	for (QString &paragraph : paragraphs)
	{
		paragraph = paragraph.trimmed();
	}

	QListIterator<QString> iter(paragraphs);
	if (mode == MessageLevel::MultiMC)
		while (iter.hasNext())
			writeColor(iter.next(), "blue", 0);
	else if (mode == MessageLevel::Error)
		while (iter.hasNext())
			writeColor(iter.next(), "red", 0);
	else if (mode == MessageLevel::Warning)
		while (iter.hasNext())
			writeColor(iter.next(), "orange", 0);
	else if (mode == MessageLevel::Fatal)
		while (iter.hasNext())
			writeColor(iter.next(), "red", "black");
	else if (mode == MessageLevel::Debug)
		while (iter.hasNext())
			writeColor(iter.next(), "green", 0);
	else if (mode == MessageLevel::PrePost)
		while (iter.hasNext())
			writeColor(iter.next(), "grey", 0);
	// TODO: implement other MessageLevels
	else
		while (iter.hasNext())
			writeColor(iter.next(), 0, 0);
	if(isVisible())
	{
		if (m_scroll_active)
		{
			bar->setValue(bar->maximum());
		}
		m_last_scroll_value = bar->value();
	}
}
开发者ID:TheGamingLabsUK,项目名称:MultiMC5,代码行数:56,代码来源:ConsoleWindow.cpp

示例7: scrollDown

void QUAboutDialog::scrollDown() {
	QScrollBar *bar = credits->verticalScrollBar();

	if(bar->value() >= bar->maximum())
		QTimer::singleShot(RESET_GAP, this, SLOT(resetText()));
	else {
		bar->setValue(bar->value() + SCROLL_STEP);
		QTimer::singleShot(SCROLL_GAP, this, SLOT(scrollDown()));
	}
}
开发者ID:escaped,项目名称:uman,代码行数:10,代码来源:QUAboutDialog.cpp

示例8: wheelEvent

void FocusedTextEdit::wheelEvent(QWheelEvent *event)
{
    // If we're already scrolled all the way to the top or bottom, we pass the
    // wheel event onto the basket.
    QScrollBar *sb = verticalScrollBar();
    if ((event->delta() > 0 && sb->value() > sb->minimum())
            || (event->delta() < 0 && sb->value() < sb->maximum()))
        KTextEdit::wheelEvent(event);
    //else
    //    Global::bnpView->currentBasket()->graphicsView()->wheelEvent(event);
}
开发者ID:AlD,项目名称:basket,代码行数:11,代码来源:focusedwidgets.cpp

示例9: 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);
}
开发者ID:vaibhavpandeyvpz,项目名称:apkstudio,代码行数:11,代码来源:imageviewerwidget.cpp

示例10: 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);
}
开发者ID:AndroidTamer,项目名称:apkstudio,代码行数:11,代码来源:viewer.cpp

示例11: 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);
}
开发者ID:KDE,项目名称:konversation,代码行数:53,代码来源:chatwindow.cpp

示例12: horizontalScrollBar

void
dmz::QtCanvasView::pan_direction (const int Dx, const int Dy) {

   QScrollBar *hBar = horizontalScrollBar ();
   QScrollBar *vBar = verticalScrollBar ();

   if (hBar && vBar) {

      hBar->setValue (hBar->value() - Dx);
      vBar->setValue (vBar->value() - Dy);
   }
}
开发者ID:Andais,项目名称:dmz,代码行数:12,代码来源:dmzQtCanvasView.cpp

示例13: mouseReleaseEvent

void PlayLabel::mouseReleaseEvent(QMouseEvent *event)
{
        QScrollBar* pHBar = m_pSclView->horizontalScrollBar();
        QScrollBar* pVBar = m_pSclView->verticalScrollBar();

        //算法:先获取之前的滚动条值,再加上横向和竖向移动的距离(鼠标按下时的位置减去移动到的位置),就是滚动条应该到的位置
        pHBar->setValue(pHBar->value() + (m_preX - event->pos().x()));
        pVBar->setValue(pVBar->value() + (m_preY - event->pos().y()));

        //清掉之前的鼠标按下时候的值
        m_preX = 0;
        m_preY = 0;
}
开发者ID:passionkk,项目名称:SZHuaqi,代码行数:13,代码来源:playlabel.cpp

示例14: mouseMoveEvent

void SCgView::mouseMoveEvent (QMouseEvent * event)
{
    if(event->buttons() & Qt::MidButton)
    {
        viewport()->setCursor(Qt::ClosedHandCursor);
        QScrollBar *hBar = horizontalScrollBar();
        QScrollBar *vBar = verticalScrollBar();
        QPoint delta = event->pos() - mPrevMousePos;
        hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x()));
        vBar->setValue(vBar->value() - delta.y());
        mPrevMousePos = event->pos();
    }

    QGraphicsView::mouseMoveEvent(event);
}
开发者ID:deniskoronchik,项目名称:kbe,代码行数:15,代码来源:scgview.cpp

示例15: slot_scrollWindow

void AnimationForm::slot_scrollWindow(QPoint move)
{
	QScrollBar *p ;

	setCursor(QCursor(Qt::ClosedHandCursor)) ;

	p = ui->scrollArea_anime->horizontalScrollBar() ;
	if ( p->isEnabled() && !p->isHidden() ) {
		p->setValue(p->value()-move.x());
	}
	p = ui->scrollArea_anime->verticalScrollBar() ;
	if ( p->isEnabled() && !p->isHidden() ) {
		p->setValue(p->value()-move.y());
	}
}
开发者ID:moximoxi,项目名称:AnimationCreator,代码行数:15,代码来源:animationform.cpp


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