• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ setSliderPosition函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中setSliderPosition函数的典型用法代码示例。如果您正苦于以下问题:C++ setSliderPosition函数的具体用法?C++ setSliderPosition怎么用?C++ setSliderPosition使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: qxt_d

/*!
    \reimp
 */
void QxtStars::mousePressEvent(QMouseEvent* event)
{
    if (qxt_d().readOnly)
    {
        event->ignore();
        return;
    }
    QAbstractSlider::mousePressEvent(event);

    if (maximum() == minimum() || (event->buttons() ^ event->button()))
    {
        event->ignore();
        return;
    }

    event->accept();
    QStyleOptionSlider opt = qxt_d().getStyleOption();
    const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
    const QPoint center = sliderRect.center() - sliderRect.topLeft();
    const int pos = qxt_d().pixelPosToRangeValue(qxt_d().pick(event->pos() - center));
    setSliderPosition(pos);
    triggerAction(SliderMove);
    setRepeatAction(SliderNoAction);
    qxt_d().snapBackPosition = pos;
    update();
}
开发者ID:develnk,项目名称:qxtweb-qt5,代码行数:29,代码来源:qxtstars.cpp


示例2: qMax

void ScrollBar::mouseMoveEvent(QMouseEvent *ev)
{
	if (mouse_grabed_) {
		// position diff
		int pos = (orientation_ == Qt::Horizontal ? ev->pos().x() : ev->pos().y()) - bar_grabed_position_;

		// fix negative
		pos = qMax(pos, 0);
		Q_ASSERT(pos >= 0);

		// fix maximum
		const qint64 value = qMin(sliderValueFromPosition(pos, drawBarSize()), maximum_);
		Q_ASSERT(value <= maximum_);

		if (isSliderDown()) {
			setSliderPosition(value);
		}

		if (hasTracking()) {
			setValue(value);
		}
	} else {
		// When mouse hovering
		if (isScrollBarArea(ev->pos())) {
			// TODO: animation
		}
	}
}
开发者ID:suma,项目名称:hex,代码行数:28,代码来源:scrollbar.cpp


示例3: qDebug

// Based on code from qslider.cpp
void Slider::mousePressEvent( QMouseEvent *e )
{
	qDebug("pressed (%d, %d)", e->pos().x(), e->pos().y());
	if( e->button() == Qt::LeftButton )
	{
		qDebug( "Left button" );
		QStyleOptionSlider opt;
		initStyleOption( &opt );
		const QRect sliderRect = style()->subControlRect( QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this );
		const QPoint center = sliderRect.center() - sliderRect.topLeft();
		// to take half of the slider off for the setSliderPosition call we use the center - topLeft

		if ( ! sliderRect.contains( e->pos() ) )
		{
			qDebug( "accept" );
			e->accept();

			int v = pixelPosToRangeValue( pick( e->pos() - center ) );
			setSliderPosition( v );
			triggerAction( SliderMove );
			setRepeatAction( SliderNoAction );
			emit sliderMoved( v );//TODO: ok?
			emit sliderPressed(); //TODO: ok?
		}
		else
		{
			QSlider::mousePressEvent( e );
		}
	}
	else
	{
		QSlider::mousePressEvent( e );
	}
}
开发者ID:MarcAntoine-Arnaud,项目名称:QtAV,代码行数:35,代码来源:Slider.cpp


示例4: sort

//-----------------------------------------------------------------------------
// Name: syncToList
// Desc: Synchronizes this slider's position with the list to which it
//       is attached.  This method is safe to call at any time and will
//       not produce an infinite loop.
//-----------------------------------------------------------------------------
void EvidyonGUIList::ListSlider::syncToList()
{
    EvidyonGUIList* owner = myOwner;
    myOwner = 0;    // prevent recursive calling of any sort (future prevention, doesn't do anything now)
    setSliderPosition(owner->getScrollIndexPercent());
    myOwner = owner;
}
开发者ID:karlgluck,项目名称:Evidyon,代码行数:13,代码来源:evidyonguilist.cpp


示例5: qRound

void ScrollBar::moveSlider(double min, double max)
{
    const int sliderTicks = qRound((max - min) / 
        (d_maxBase - d_minBase) * d_baseTicks);

    // setRange initiates a valueChanged of the scrollbars
    // in some situations. So we block
    // and unblock the signals.

    blockSignals(true);

    setRange(sliderTicks / 2, d_baseTicks - sliderTicks / 2);
    int steps = sliderTicks / 200;
    if ( steps <= 0 )
        steps = 1;

    setSingleStep(steps);
    setPageStep(sliderTicks);

    int tick = mapToTick(min + (max - min) / 2);
    if ( isInverted() )
        tick = d_baseTicks - tick;

    setSliderPosition(tick);
    blockSignals(false);
}
开发者ID:duckens,项目名称:projects,代码行数:26,代码来源:scrollBar.cpp


示例6: setSliderPosition

void Knob::updatePosition(int val)
{
    setSliderPosition(val);
    setToolTip(QString::number(val));
    update();
    emit sliderMoved(val);
}
开发者ID:tedr56,项目名称:Fluxus-Qinterface,代码行数:7,代码来源:knob.cpp


示例7: Q_D

void DSlider::mouseMoveEvent(QMouseEvent *event)
{
    QAbstractSlider::mouseMoveEvent(event);

    Q_D(DSlider);

    if(d->mousePressed) {
        int newPosition = d->pixelPosToRangeValue(d->pick(event->pos()) - d->clickOffset);
        setSliderPosition(newPosition);

        emit sliderMoved(newPosition);
    }

    if (!d->m_hoverShowValue) {
        return;
    }

    QPoint pos = event->pos();
    QRect rect(d->getScalePosition(value()) - CustomDrawingLeftPadding, 10, 20, 20);
    if (d->m_handleHovering) {
        d->m_handleHovering = rect.contains(pos);
    } else {
        d->m_handleHovering = rect.contains(pos);
        if (d->m_handleHovering) {
            d->m_hoverTimout = false;
            if (d->m_hoverShowValueInterval > 0) {
                d->m_hoverTimer.start(d->m_hoverShowValueInterval);
            }
        }
    }

    update();
}
开发者ID:zccrs,项目名称:deepin-tool-kit,代码行数:33,代码来源:dslider.cpp


示例8: switch

void HudSlider::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
    if (!d->hasValidRange()) {
        return;
    }
    const int pos = d->positionForX(event->pos().x());
    if (d->mHandleRect.contains(event->pos())) {
        switch (event->button()) {
        case Qt::LeftButton:
            d->mIsDown = true;
            break;
        case Qt::MiddleButton:
            setSliderPosition(pos);
            triggerAction(QAbstractSlider::SliderMove);
            break;
        default:
            break;
        }
    } else {
        d->mRepeatX = event->pos().x();
        d->mRepeatAction = pos < d->mSliderPosition
                           ? QAbstractSlider::SliderPageStepSub
                           : QAbstractSlider::SliderPageStepAdd;
        doRepeatAction(FIRST_REPEAT_DELAY);
    }
    update();
}
开发者ID:KDE,项目名称:gwenview,代码行数:27,代码来源:hudslider.cpp


示例9: Q_D

/*!
    \reimp
*/
void QScrollBar::mousePressEvent(QMouseEvent *e)
{
    Q_D(QScrollBar);

    if (d->repeatActionTimer.isActive())
        d->stopRepeatAction();

    bool midButtonAbsPos = style()->styleHint(QStyle::SH_ScrollBar_MiddleClickAbsolutePosition,
                                             0, this);
    QStyleOptionSlider opt;
    initStyleOption(&opt);

    if (d->maximum == d->minimum // no range
        || (e->buttons() & (~e->button())) // another button was clicked before
        || !(e->button() == Qt::LeftButton || (midButtonAbsPos && e->button() == Qt::MidButton)))
        return;

    d->pressedControl = style()->hitTestComplexControl(QStyle::CC_ScrollBar, &opt, e->pos(), this);
    d->pointerOutsidePressedControl = false;

    QRect sr = style()->subControlRect(QStyle::CC_ScrollBar, &opt,
                                       QStyle::SC_ScrollBarSlider, this);
    QPoint click = e->pos();
    QPoint pressValue = click - sr.center() + sr.topLeft();
    d->pressValue = d->orientation == Qt::Horizontal ? d->pixelPosToRangeValue(pressValue.x()) :
        d->pixelPosToRangeValue(pressValue.y());
    if (d->pressedControl == QStyle::SC_ScrollBarSlider) {
        d->clickOffset = HORIZONTAL ? (click.x()-sr.x()) : (click.y()-sr.y());
        d->snapBackPosition = d->position;
    }

    if ((d->pressedControl == QStyle::SC_ScrollBarAddPage
          || d->pressedControl == QStyle::SC_ScrollBarSubPage)
        && ((midButtonAbsPos && e->button() == Qt::MidButton)
            || (style()->styleHint(QStyle::SH_ScrollBar_LeftClickAbsolutePosition, &opt, this)
                && e->button() == Qt::LeftButton))) {
        int sliderLength = HORIZONTAL ? sr.width() : sr.height();
        setSliderPosition(d->pixelPosToRangeValue((HORIZONTAL ? e->pos().x()
                                                              : e->pos().y()) - sliderLength / 2));
        d->pressedControl = QStyle::SC_ScrollBarSlider;
        d->clickOffset = sliderLength / 2;
    }
    const int initialDelay = 500; // default threshold
    QElapsedTimer time;
    time.start();
    d->activateControl(d->pressedControl, initialDelay);
    repaint(style()->subControlRect(QStyle::CC_ScrollBar, &opt, d->pressedControl, this));
    if (time.elapsed() >= initialDelay && d->repeatActionTimer.isActive()) {
        // It took more than 500ms (the initial timer delay) to process
        // the control activation and repaint(), we therefore need
        // to restart the timer in case we have a pending mouse release event;
        // otherwise we'll get a timer event right before the release event,
        // causing the repeat action to be invoked twice on a single mouse click.
        // 50ms is the default repeat time (see activateControl/setRepeatAction).
        d->repeatActionTimer.start(50, this);
    }
    if (d->pressedControl == QStyle::SC_ScrollBarSlider)
        setSliderDown(true);
}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:62,代码来源:qscrollbar.cpp


示例10: QSlider

QVolumeSlider::QVolumeSlider(QWidget *parent) :
    QSlider(parent)
{
    setRange(0,1000);
    connect(this, SIGNAL(valueChanged(int)), this, SLOT(updateVolume(int)));
    setValue(1000);
    setSliderPosition(1000);
}
开发者ID:sun-friderick,项目名称:MusicPlayerLinux,代码行数:8,代码来源:qvolumeslider.cpp


示例11: Q_D

/*!
    \reimp
*/
void QSlider::mousePressEvent(QMouseEvent *ev)
{
    Q_D(QSlider);
    if (d->maximum == d->minimum || (ev->buttons() ^ ev->button())) {
        ev->ignore();
        return;
    }
#ifdef QT_KEYPAD_NAVIGATION
    if (QApplication::keypadNavigationEnabled())
        setEditFocus(true);
#endif
    ev->accept();
    if ((ev->button() & style()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons)) == ev->button()) {
        QStyleOptionSlider opt;
        initStyleOption(&opt);
        const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
        const QPoint center = sliderRect.center() - sliderRect.topLeft();
        // to take half of the slider off for the setSliderPosition call we use the center - topLeft

        setSliderPosition(d->pixelPosToRangeValue(d->pick(ev->pos() - center)));
        triggerAction(SliderMove);
        setRepeatAction(SliderNoAction);
        d->pressedControl = QStyle::SC_SliderHandle;
        update();
    } else if ((ev->button() & style()->styleHint(QStyle::SH_Slider_PageSetButtons)) == ev->button()) {
        QStyleOptionSlider opt;
        initStyleOption(&opt);
        d->pressedControl = style()->hitTestComplexControl(QStyle::CC_Slider,
                                                           &opt, ev->pos(), this);
        SliderAction action = SliderNoAction;
        if (d->pressedControl == QStyle::SC_SliderGroove) {
            const QRect sliderRect = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
            int pressValue = d->pixelPosToRangeValue(d->pick(ev->pos() - sliderRect.center() + sliderRect.topLeft()));
            d->pressValue = pressValue;
            if (pressValue > d->value)
                action = SliderPageStepAdd;
            else if (pressValue < d->value)
                action = SliderPageStepSub;
            if (action) {
                triggerAction(action);
                setRepeatAction(action);
            }
        }
    } else {
        ev->ignore();
        return;
    }

    if (d->pressedControl == QStyle::SC_SliderHandle) {
        QStyleOptionSlider opt;
        initStyleOption(&opt);
        setRepeatAction(SliderNoAction);
        QRect sr = style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
        d->clickOffset = d->pick(ev->pos() - sr.topLeft());
        update(sr);
        setSliderDown(true);
    }
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:61,代码来源:qslider.cpp


示例12: signalsBlocked

  void QScaleSlider::SetPosWithBlockedSignals(double pos)
  {
    bool const b = signalsBlocked();
    blockSignals(true);

    setSliderPosition(my::rounds(pos * m_factor));

    blockSignals(b);
  }
开发者ID:Mapotempo,项目名称:omim,代码行数:9,代码来源:slider_ctrl.cpp


示例13: setSliderPosition

void Slider::mousePressEvent(QMouseEvent *e)
{
    int handlePos = QStyle::sliderPositionFromValue(minimum(),maximum(),sliderPosition(),width());
    if(handlePos<e->pos().x()-5||handlePos>e->pos().x()+5)
    {
        int position = QStyle::sliderValueFromPosition(minimum(),maximum(),e->pos().x(),width());
        setSliderPosition(position);
        emit sliderMoved(sliderPosition());
    }
}
开发者ID:raf924,项目名称:iniTunes,代码行数:10,代码来源:slider.cpp


示例14: maximum

void ThumbSlider::mouseMoveEvent(QMouseEvent *event)
{
	if (event->buttons() && Qt::LeftButton)
	{
		int value = QStyle::sliderValueFromPosition(minimum(), maximum(), event->x(), width(), false);

		setSliderPosition(value);
		triggerAction(SliderMove);
	}
}
开发者ID:BackupTheBerlios,项目名称:avidemux-svn,代码行数:10,代码来源:T_thumbSlider.cpp


示例15: qBound

void HudSlider::setValue(int value)
{
    value = qBound(d->mMin, value, d->mMax);
    if (value != d->mValue) {
        d->mValue = value;
        setSliderPosition(value);
        update();
        valueChanged(d->mValue);
    }
}
开发者ID:KDE,项目名称:gwenview,代码行数:10,代码来源:hudslider.cpp


示例16: setSliderPosition

void HudSlider::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
    if (!d->hasValidRange()) {
        return;
    }
    if (d->mIsDown) {
        setSliderPosition(d->positionForX(event->pos().x()));
        triggerAction(QAbstractSlider::SliderMove);
        update();
    }
}
开发者ID:KDE,项目名称:gwenview,代码行数:11,代码来源:hudslider.cpp


示例17: qMin

void HudSlider::wheelEvent(QGraphicsSceneWheelEvent* event)
{
    if (!d->hasValidRange()) {
        return;
    }
    int step = qMin(QApplication::wheelScrollLines() * d->mSingleStep, d->mPageStep);
    if ((event->modifiers() & Qt::ControlModifier) || (event->modifiers() & Qt::ShiftModifier)) {
        step = d->mPageStep;
    }
    setSliderPosition(d->mSliderPosition + event->delta() * step / 120);
    triggerAction(QAbstractSlider::SliderMove);
}
开发者ID:KDE,项目名称:gwenview,代码行数:12,代码来源:hudslider.cpp


示例18: Q_D

void QDial::mouseMoveEvent(QMouseEvent * e)
{
    Q_D(QDial);
    if (!(e->buttons() & Qt::LeftButton)) {
        e->ignore();
        return;
    }
    e->accept();
    d->doNotEmit = true;
    setSliderPosition(d->valueFromPoint(e->pos()));
    d->doNotEmit = false;
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:12,代码来源:qdial.cpp


示例19: Q_ASSERT

void ParameterSlider::setValues(const vint& values, const QStringList& labels)
{
    Q_ASSERT(values.size() == labels.size());
    m_values = values;
    m_labels = labels;

    setEnabled(m_values.size() > 1);

    if (!m_values.empty()) {
        m_ui->slider->setRange(0, m_values.size() - 1);
        setSliderPosition(0);
    }
}
开发者ID:novokrest,项目名称:Photo,代码行数:13,代码来源:parameterslider.cpp


示例20: log

void ScrollBar::moveSlider(double min, double max)
{
  if (mLogScale)
    {
      min = log(min);
      max = log(max);
    }

  int sliderTicks;
  sliderTicks = qRound((max - min) /
                       (d_maxBase - d_minBase) * d_baseTicks);

  // setRange initiates a valueChanged of the scrollbars
  // in some situations. So we block
  // and unblock the signals.

  blockSignals(true);

  setRange(sliderTicks / 2, d_baseTicks - sliderTicks / 2);
  int steps = sliderTicks / 200;

  if (steps <= 0)
    steps = 1;

#if QT_VERSION < 0x040000
  setSteps(steps, sliderTicks);
#else
  setSingleStep(steps);
  setPageStep(sliderTicks);
#endif

  int tick;
  tick = mapToTick(min + (max - min) / 2);

  if (isInverted())
    tick = d_baseTicks - tick;

#if QT_VERSION < 0x040000
  directSetValue(tick);
  rangeChange();
#else
  setSliderPosition(tick);
#endif
  blockSignals(false);
}
开发者ID:ShuoLearner,项目名称:COPASI,代码行数:45,代码来源:scrollbar.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ setSocket函数代码示例发布时间:2022-05-30
下一篇:
C++ setSizePolicy函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap