Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved QScroller crash after deleting QListWidget on Android

    Mobile and Embedded
    1
    1
    239
    Loading More Posts
    • 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.
    • M
      mikhail_kr last edited by mikhail_kr

      To test QScroller on my Android device,
      I have written a simple HelloWorld-like application with QStackedWidget with 2 pages.
      Every page has a single QListWidget with a number of items.
      On startup, the app shows page_2 of the stacked widget with a number of items. QScroller is attached programmatically to this QListWidget:

      MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
      {
      ui->setupUi(this);

      ui->stackedWidget->setCurrentIndex(1);
      
      scroller = QScroller::scroller(ui->listWidget_2);
      scroller->grabGesture(ui->listWidget_2);
      

      }

      On application startup everything is ok. QScroller attached is working fine with the QListWidget.

      After that I press "Go to page 1" button which removes the entire page from the stacked widget and attach QScroller to the second QListWidget :

      void MainWindow::on_pushButton_clicked()
      {
      QScroller::ungrabGesture(ui->listWidget_2);

      ui->stackedWidget->removeWidget(ui->page_2);
      ui->page_2->deleteLater();
      ui->page_2 = nullptr;
      
      QScroller* scroller2 = QScroller::scroller(ui->listWidget);
      scroller2->grabGesture(ui->listWidget);
      

      }

      The widget is displayed OK. But when I try to scroll it with my fingers, the app crashes with SIGSEGV(Segmentation fault) and the stack is:

      #10 qtMainLoopThread

      1. QWidget* object_cast<QWidget*>(QObject*)
      2. QFlickGestureRecognizer::recognize(QGesture*, QObject*, QEvent*)
      3. ???

      What am i doing wrong???

      The complete source code of the application:
      https://yadi.sk/d/hothr7gx3YpG2A

      1 Reply Last reply Reply Quote 0
      • First post
        Last post