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. Update part of the scrolling QWidget inside QScrollArea
Forum Updated to NodeBB v4.3 + New Features

Update part of the scrolling QWidget inside QScrollArea

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 908 Views 2 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.
  • MarKSM Offline
    MarKSM Offline
    MarKS
    wrote on last edited by MarKS
    #1

    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.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      MarKSM 1 Reply Last reply
      1
      • SGaistS SGaist

        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.

        MarKSM Offline
        MarKSM Offline
        MarKS
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

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

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          MarKSM 1 Reply Last reply
          0
          • SGaistS SGaist

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

            MarKSM Offline
            MarKSM Offline
            MarKS
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

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

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              MarKSM 1 Reply Last reply
              0
              • SGaistS SGaist

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

                MarKSM Offline
                MarKSM Offline
                MarKS
                wrote on last edited by
                #7

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

                P 1 Reply Last reply
                0
                • MarKSM MarKS

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

                  P Offline
                  P Offline
                  pourjour
                  wrote on last edited by
                  #8

                  @MarKS Can you please share with us what you discovered until now, that would be helpful for anyone facing the same issue as yours, like me. please.

                  1 Reply Last reply
                  0

                  • Login

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