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. Lazy loading in QScrollArea

Lazy loading in QScrollArea

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 4 Posters 2.6k Views 3 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.
  • V Offline
    V Offline
    Viki_Dev
    wrote on last edited by
    #1

    Hello folks,

    I have been trying to implement lazy loading in QScrollarea. Widget are being added (say 20 Qlabel) at bottom and same number of widgets are being deleted from top.
    Problem is, scrollbar or scrolling is happening automatically not in normal fashion way.
    As soon as i delete item from top, all bottom item move up and scrolling gets disturbed.
    Can anybody help with situation.?

    raven-worxR 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      I assume you are using a layout on the scroll area which means
      that the layout will adjust when you delete widgets.
      You can try to disable the layout before you remove the top ones and
      enable again when ready.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Viki_Dev
        wrote on last edited by
        #3

        I tried doing it, but effect is weird

        ui->scrollAreaWidgetContents->layout()->setEnabled(false);
        ui->scrollArea->verticalScrollBar()->setEnabled(false);
        updateScrollAreaPage();
        ui->scrollArea->verticalScrollBar()->setEnabled(true);
        ui->scrollAreaWidgetContents->layout()->setEnabled(true);

        after doing this layout autoscrolling stops,but futher scrolling all item get remove something weird happens

        mrjjM J.HilkJ 2 Replies Last reply
        0
        • V Viki_Dev

          I tried doing it, but effect is weird

          ui->scrollAreaWidgetContents->layout()->setEnabled(false);
          ui->scrollArea->verticalScrollBar()->setEnabled(false);
          updateScrollAreaPage();
          ui->scrollArea->verticalScrollBar()->setEnabled(true);
          ui->scrollAreaWidgetContents->layout()->setEnabled(true);

          after doing this layout autoscrolling stops,but futher scrolling all item get remove something weird happens

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Viki_Dev
          ok, i have not tried such setup with scrollarea
          so not sure what "something weird happens" covers.

          Using a listview with delegate is not an option?

          V 1 Reply Last reply
          0
          • V Viki_Dev

            Hello folks,

            I have been trying to implement lazy loading in QScrollarea. Widget are being added (say 20 Qlabel) at bottom and same number of widgets are being deleted from top.
            Problem is, scrollbar or scrolling is happening automatically not in normal fashion way.
            As soon as i delete item from top, all bottom item move up and scrolling gets disturbed.
            Can anybody help with situation.?

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #5

            @Viki_Dev

            1. add a custom QWidget into the scroll area
            2. in this custom widget set a fixed size (setFixedSize()) of the sizeHint() from the layout
            3. when you now add a widget the scrolling doesn't "jump"
            4. now repeat step (2) after scrolling is done and the scrollbar can be adapted

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • V Viki_Dev

              I tried doing it, but effect is weird

              ui->scrollAreaWidgetContents->layout()->setEnabled(false);
              ui->scrollArea->verticalScrollBar()->setEnabled(false);
              updateScrollAreaPage();
              ui->scrollArea->verticalScrollBar()->setEnabled(true);
              ui->scrollAreaWidgetContents->layout()->setEnabled(true);

              after doing this layout autoscrolling stops,but futher scrolling all item get remove something weird happens

              J.HilkJ Offline
              J.HilkJ Offline
              J.Hilk
              Moderators
              wrote on last edited by
              #6

              @Viki_Dev

              hi,
              try the following:

              ui->scrollArea->blockSignals(true);
              updateScrollAreaPage();
              ui->scrollArea->blockSignals(false);
              

              howerver, ita untested from my side


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              raven-worxR 1 Reply Last reply
              0
              • J.HilkJ J.Hilk

                @Viki_Dev

                hi,
                try the following:

                ui->scrollArea->blockSignals(true);
                updateScrollAreaPage();
                ui->scrollArea->blockSignals(false);
                

                howerver, ita untested from my side

                raven-worxR Offline
                raven-worxR Offline
                raven-worx
                Moderators
                wrote on last edited by raven-worx
                #7

                @J.Hilk
                my guess is that this doesn't change anything, since there happens so much more (event-driven) in the background than signals from the scrollarea

                --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                If you have a question please use the forum so others can benefit from the solution in the future

                J.HilkJ 1 Reply Last reply
                0
                • raven-worxR raven-worx

                  @J.Hilk
                  my guess is that this doesn't change anything, since there happens so much more (event-driven) in the background than signals from the scrollarea

                  J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  @raven-worx you're mostlikly right, x) didn't think it through enough, I guess.
                  Had a long morning...


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  1 Reply Last reply
                  0
                  • mrjjM mrjj

                    @Viki_Dev
                    ok, i have not tried such setup with scrollarea
                    so not sure what "something weird happens" covers.

                    Using a listview with delegate is not an option?

                    V Offline
                    V Offline
                    Viki_Dev
                    wrote on last edited by
                    #9

                    @mrjj said in Lazy loading in QScrollArea:

                    ething weird h

                    no, not an option, thanks for your effort

                    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