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. Performance problems with bulk showing/hiding widgets.
QtWS25 Last Chance

Performance problems with bulk showing/hiding widgets.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.1k Views
  • 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.
  • N Offline
    N Offline
    Narnith
    wrote on last edited by
    #1

    An application I'm developing has, among other things, a scroll view containing many instances of a custom widget, which are created at run time. This widget (technically a QFrame) contains two QPushButtons and three QLabels, one of which is always showing an image - think 200x150 pixels, ish. Each widget has a unique picture, again generated at runtime. There are potentially a very large number of these widgets, think along the order of 2-3 thousand.

    Now, the problem I'm running into is this: the application contains a search functionality that is used to show/hide some of these widgets based on the input criteria. When the program decides whether to hide or show a widget, it calls either show() or hide() on it. I've noticed that show() is much slower than hide(), which makes sense. However, due to the number of widgets, it results in lag times that are unacceptable.

    I'm not sure how I can go about solving this problem. I've thought about trying a QStackedWidget, with one page for the currently shown widgets, and other for the "hidden widgets" (not really hidden, just on in a view on another page or something), and moving them between the pages as appropriate, but I have no idea if that would be faster at all. At this point in my search I'm very willing to do dirty hacks.

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

      Hi and welcome to devnet,

      I'd rather try to bring the number of widgets down. Do you really need that many at the same time ? Wouldn't having only a fixed number of them and then updating their content be something doable ?

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

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Narnith
        wrote on last edited by
        #3

        [quote author="SGaist" date="1424381935"]Hi and welcome to devnet,

        I'd rather try to bring the number of widgets down. Do you really need that many at the same time ? Wouldn't having only a fixed number of them and then updating their content be something doable ?[/quote]

        Thanks for the reply.

        I've thought about doing that, and if I don't find a solution I may end up going with this. But it's not how the application is expected to work.

        RAM isn't a concern in the slightest, so that's not a problem either.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          alex_malyu
          wrote on last edited by
          #4

          Ram may be not a concern, but performance is.
          Allocation/deleting memory, construction/deconstruction is a performance killer.
          Most approaches implemented in Qt ( QTableWidget for example) follow the design pattern SGaist mentioned.
          I bet for a reason.

          Alex

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

            alex_malyu is right RAM is not everything.

            If you really need that much controls you might better go with QGraphicsView and friends but don't put widgets in there

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

            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