Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. scroll items by using touching (dragging) without using scrollbar in QScrollArea
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Binary SoftB Offline
    Binary SoftB Offline
    Binary Soft
    wrote on last edited by Binary Soft
    #1

    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 );
        }
    
    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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.

      http://doc.qt.io/qt-5/qscroller.html

      Binary SoftB 1 Reply Last reply
      2
      • mrjjM mrjj

        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.

        http://doc.qt.io/qt-5/qscroller.html

        Binary SoftB Offline
        Binary SoftB Offline
        Binary Soft
        wrote on last edited by
        #3

        Thanks @mrjj .
        It works.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved