scroll items by using touching (dragging) without using scrollbar in QScrollArea
Unsolved
General and Desktop
-
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?
Thanks
/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 ); }
-
Hi
And welcome to the forums.
I made a combobox touch scroll able by
QScroller::grabGesture(ui->combo->view()->viewport(),QScroller::LeftMouseButtonGesture);
I assume you can do something like for scrollArea too. -
Hi
And welcome to the forums.
I made a combobox touch scroll able by
QScroller::grabGesture(ui->combo->view()->viewport(),QScroller::LeftMouseButtonGesture);
I assume you can do something like for scrollArea too.Thanks @mrjj .
It works.