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

Update part of the scrolling QWidget inside QScrollArea



  • My issue is very much similar to the issue explained here.

    I am developing a video player where I need a scrolling timeline with columns designated as frames. If the video stream has 500,000 frames then I have 500,000 columns custom drawn on the widget. I made a custom QWidget inside a QScrollArea and I use paintEvent() to draw columns and text using QPainter.

    Right now, in my implementation, I move the widget horizontally when the user clicks on Play. This causes my paintEvent() to be triggered and starts drawing the whole widget again. This causes my stream playing experience laggy and choppy.

    Things I have tried:

    • Converting my QWidget class to QOpenGLWidget with paintEvent() -> results in the complete black widget and doesn't paint anything. As discussed here. Doesn't solve my issue though.
    • Drawing the custom widget once in paintEvent() and moving it -> when the area in the viewport() is scrolled it doesn't paint anymore.

    Also, I noticed using drawText() of QPainter is pretty slow. There are a lot of bug tickets regarding this issue.

    What are my options here? Any efficient method to optimize this issue?

    I'm using Qt 5.7.1 on Win 10. Sorry I am not allowed to use newer versions of Qt.

    Edit1 : This is how my custom widget looks like

    Screenshot 2021-04-12 202226.jpg

    As my red seek bar moves to the right my custom widget scrolls horizontally to the left.


  • Lifetime Qt Champion

    Hi,

    You might want to consider using Qt's model view framework. Using a custom view on top of a QAbtractListModel that would contain your frames. You might also want to consider lazy loading the images and have a moving window rather that having everything loaded at the same time.



  • @SGaist Ok. I feel my question is not well-framed. I do not show any images on my custom widget. I only draw columns and text showing frame numbers on top.


  • Lifetime Qt Champion

    Then my suggestion still applies but your model will be lighter.



  • @SGaist Can you post a small sample as to how I could achieve that? Would be helpful.


  • Lifetime Qt Champion

    An example of a model saying it has one column of 500'000 row ?



  • @SGaist Nevermind. I think I understood how I need to implement it. Thank you!


Log in to reply