Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Smooth automatic scrolling in QScrollArea (or something else?)



  • Hello,
    I'm quite new to QT and have a problem with a QScrollArea animation:
    I want the content of the QScrollArea smoothly scroll down automatically over several seconds.
    For now I tried this by using a QTimer that calls ensureVisibility(0, top, 0, 0) every few milliseconds (15-30) and increases the top-value by 1 or 2 Pixels per call.

    Inside the QScrollArea I want to display a "table-like" structure. The only use of this program is to present the displayed information.

    When using my "solution" (its more like a first attempt) the CPU usage is about 20% on my Laptop - but it works
    Because I want this to run on a Raspberry-Pi, my program has massive lags.

    While still having problems with getting QT5 with EGL on my Raspberry Pi, the application opens with linuxfb or in x-server - but instead of scrolling the screen in about 15 seconds you have to wait a minute to see it move about 2 pixels.

    The full test code is available here: https://github.com/MyTFG/raspVtp

    What can I do to reduce the CPU usage and/or make it run smoothly?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Since it's tabular data, why not use a QTableView ?

    By the way it's Qt, QT stands for Apple QuickTime.



  • Hi, thank you for your response :)
    I could use a QTableView - but I guess this would not solve my problem with scrolling, since i have to move the content there as well or am I wrong with this?


  • Lifetime Qt Champion

    The rendering part of the QTableView is optimized for that kind of data. After a quick look at your code, it seems you are generating lots of widgets to show your data, here you would only have one.