scroll items by using touching (dragging) without using scrollbar in QScrollArea

  • Hi,
    I add dynamically buttons in QScrollArea. I want scroll up and down by using touch items (drag with mouse or touch screen). I do not want to scroll from vertical scroll bar so I hide it.

    How can I sove it?


    /QScrollArea *scrollArea = new QScrollArea( this );
        scrollArea->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff );
        scrollArea->setWidgetResizable( true );
        scrollArea->setGeometry( 10, 10, 200, 200 );
        QWidget *widget = new QWidget();
        scrollArea->setWidget( widget );
        QVBoxLayout *layout = new QVBoxLayout();
        widget->setLayout( layout );
        for (int i = 0; i < 10; i++)
            QPushButton *button = new QPushButton( QString( "%1" ).arg( i ) );
            layout->addWidget( button );

  • Lifetime Qt Champion

    And welcome to the forums.
    I made a combobox touch scroll able by
    I assume you can do something like for scrollArea too.

  • Thanks @mrjj .
    It works.

Log in to reply