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
As my red seek bar moves to the right my custom widget scrolls horizontally to the left.
-
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.
-
Then my suggestion still applies but your model will be lighter.
-
An example of a model saying it has one column of 500'000 row ?