Logo Search packages:      
Sourcecode: qt4-x11 version File versions

void QAbstractSlider::wheelEvent ( QWheelEvent e  )  [protected, virtual, inherited]

Reimplemented from QWidget.

Definition at line 658 of file qabstractslider.cpp.

References QEvent::accept(), QRect::contains(), QWheelEvent::delta(), QEvent::ignore(), QInputEvent::modifiers(), QWheelEvent::orientation(), QWheelEvent::pos(), QWidget::rect, and QAbstractSlider::triggerAction().

{
    Q_D(QAbstractSlider);
    e->ignore();
    if (e->orientation() != d->orientation && !rect().contains(e->pos()))
        return;

    static qreal offset = 0;
    static QAbstractSlider *offset_owner = 0;
    if (offset_owner != this){
        offset_owner = this;
        offset = 0;
    }

    int step = qMin(QApplication::wheelScrollLines() * d->singleStep, d->pageStep);
    if ((e->modifiers() & Qt::ControlModifier) || (e->modifiers() & Qt::ShiftModifier))
        step = d->pageStep;
    offset += e->delta() * step / 120;
    if (d->invertedControls)
        offset = -offset;

    if (qAbs(offset) < 1)
        return;

    int prevValue = d->value;
    d->position = d->value + int(offset); // value will be updated by triggerAction()
    triggerAction(SliderMove);
    if (prevValue == d->value) {
        offset = 0;
    } else {
        offset -= int(offset);
        e->accept();
    }
}


Generated by  Doxygen 1.6.0   Back to index