Important: Please read the Qt Code of Conduct -

[Solved] QTableWidget vertical scroll bars drag handle up & down motion is backwards ?

  • When using the Windows notepad app, for example, you drag the handle up to scroll-up, and down to scroll-down.

    I have a QTableWidget that under Windows is controlled by opposite mouse-drag movements?

    • The mouse scroll wheel scrolls vertical handle up and down as expected.
    • I must use opposite mouse motion to drag scroll handle up and down.
    • I cannot drag handle down when handle is at top already. I have to drag it up to move it down?

    My app has backwards mouse-drag-handle scrolling under both Windows, and OSX.

    Thanks in advance for any suggestions,


  • Lifetime Qt Champion


    Can you share a minimal compilable sample code that shows what happens ?

  • Thank you very much for taking the time to make me think.

    I ran a Qt table example and vertical scroll drag worked normally.

    My problem was I had conditional code to enable kinetic scrolling that set QScrollerProperties to make it work more native-like on Android and iOS.

    Since my MacBook has a touchpad it was considered a touch device since 1 <= QTouchDevice::maximumTouchPoints(). Since I was running Windows in a VM Fusion VM I think the touch hardware was detected in the VM as well.

    My fix was to skip this if not Android or iOS and the scroll behavior is back to normal.

    Sorry, I should have thought about making a minimal test case.

    Thank you very much for your time!


  • In case others are working on iOS and Android widget apps, this is what I am using:

    I pass my scroll area:

    /// Enables kinetic swipe or flick scrolling on touch devices
    /// param[in] scrollArea the QScrollArea or object derived from, for example,
    /// QTableWidget.
    /// QAbstractItemView::ScrollPerPixel
    /// ---------------------------------
    /// For a QTableWidget it is recommended to also set QAbstractItemView::ScrollPerPixel
    /// to enable smooth scrolling compared to ScrollPerItem
    /// Example:
    /// \code
    /// tableView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
    /// tableView->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
    /// \endcode
    void TouchWidget::setupKineticScrolling(QObject *scrollArea)
    QAbstractItemView abstractItemView = qobject_cast<QAbstractItemView>(scrollArea);
    if(0 != abstractItemView)
    if(cms::crossplatform::isTouchDevice() && cms::crossplatform::isMobileDevice())
    // QAbstractItemView::ScrollPerPixel results in smooth scrolling compared to ScrollPerItem

    QAbstractScrollArea *abstractScrollArea = qobject_cast<QAbstractScrollArea*>(scrollArea);
    if(0 != abstractScrollArea)
        Qt::ScrollBarPolicy scrollBarPolicy = Qt::ScrollBarAsNeeded;
        if(cms::crossplatform::isTouchDevice() && cms::crossplatform::isMobileDevice())
            scrollBarPolicy =  Qt::ScrollBarAlwaysOff;
    if(false == cms::crossplatform::isMobileDevice())
    // Something in this section made the vertical scroll bar handle-drag control work backwards
    // on desktop OS X and Windows.
    // Execute this section for Android or iOS only.
    // Adjust OvershootPolicy so it does not look wobbly, like table not attached to widget
    QScrollerProperties properties = QScroller::scroller(scrollArea)->scrollerProperties();
    QVariant overshootPolicy =


  • Lifetime Qt Champion

    You're welcome !

    Thanks for sharing your setup code :)

  • Hello! I put this code to my program, but i it crash in start. What am i doing wrong?
    QScrollArea* scrollFullSolution = new QScrollArea;
    QAbstractItemView* view = qobject_cast<QAbstractItemView*>(scrollFullSolution);
    Debugger show, that view is always NULL pointer. Why?

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    scrollFullSolution is a pointer to a QScrollArea not a QAbstractItemView that's why qobject_cast returns 0.

    PS: next time please start a new thread for your problem rather than highjack someone else's.

  • SGaist, thanks for answer! How can i use these two methods for my QScrollArea? I fully repeat the EdOfTheMountain's code, but it does not give positive result...

  • Lifetime Qt Champion

    What are you getting ?

  • I found a solution for this problem. I used QScrollArea::horizontal(vertical)ScrollBar::setSingleStep(1). Now scroll smoothly and quickly :)

Log in to reply