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. The window lags while resizing if there are too many checkboxes.

The window lags while resizing if there are too many checkboxes.

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 5 Posters 350 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.
  • S Offline
    S Offline
    SGaist
    Lifetime Qt Champion
    wrote 19 days ago last edited by
    #2

    Hi and welcome to devnet,

    How are you generating these checkboxes ?
    Do you have a reimplemented resizeEvent function ?

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

    3 1 Reply Last reply 19 days ago
    0
    • S SGaist
      19 days ago

      Hi and welcome to devnet,

      How are you generating these checkboxes ?
      Do you have a reimplemented resizeEvent function ?

      3 Offline
      3 Offline
      3xotic
      wrote 19 days ago last edited by
      #3

      @SGaist I do not have a reimplemented resizeEvent function, this is how I create the checkboxes:

      // Paths Group
      QGroupBox* pathsGroup = new QGroupBox("Paths");
      QVBoxLayout* pathsLayout = new QVBoxLayout;
      QPushButton* selectAllPaths = new QPushButton("Select All Paths");
      QPushButton* deselectAllPaths = new QPushButton("Deselect All Paths");
      pathsLayout->addWidget(selectAllPaths);
      pathsLayout->addWidget(deselectAllPaths);
      QList<QCheckBox*> pathCheckboxes;
      for (const QString& s : paths) {
          auto cb = new QCheckBox(s);
          pathCheckboxes.append(cb);
          pathsLayout->addWidget(cb);
      }
      pathsLayout->addStretch();
      pathsGroup->setLayout(pathsLayout);
      
      // Registry Keys Group
      QGroupBox* registryGroup = new QGroupBox("Registry Keys");
      QVBoxLayout* registryLayout = new QVBoxLayout;
      QPushButton* selectAllRegistry = new QPushButton("Select All Keys");
      QPushButton* deselectAllRegistry = new QPushButton("Deselect All Keys");
      registryLayout->addWidget(selectAllRegistry);
      registryLayout->addWidget(deselectAllRegistry);
      QList<QCheckBox*> registryCheckboxes;
      for (const QString& s : registryKeys) {
          auto cb = new QCheckBox(s);
          registryCheckboxes.append(cb);
          registryLayout->addWidget(cb);
      }
      registryLayout->addStretch();
      registryGroup->setLayout(registryLayout);
      
      1 Reply Last reply
      0
      • H Offline
        H Offline
        hskoglund
        wrote 19 days ago last edited by
        #4

        If those QStringLists paths and registrykeys do not change during the run of your app, consider moving the creation code out of your reiimplemented resizeEvent function, say to a function that's called at the start of your app. Then the resizing will be smoother.

        P 1 Reply Last reply 19 days ago
        1
        • H hskoglund
          19 days ago

          If those QStringLists paths and registrykeys do not change during the run of your app, consider moving the creation code out of your reiimplemented resizeEvent function, say to a function that's called at the start of your app. Then the resizing will be smoother.

          P Offline
          P Offline
          Pl45m4
          wrote 19 days ago last edited by
          #5

          @hskoglund said in The window lags while resizing if there are too many checkboxes.:

          consider moving the creation code out of your reiimplemented resizeEvent function

          But @3xotic stated that it's not inside resizeEvent.

          @3xotic Do you update something else on resize? Do you repaint manually somewhere?
          Usually it should not lag when resizing that few widgets...


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          3 1 Reply Last reply 18 days ago
          0
          • H Offline
            H Offline
            hskoglund
            wrote 19 days ago last edited by
            #6

            Sorry my bad, I misread his reply!

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kent-Dorfman
              wrote 19 days ago last edited by
              #7
              This post is deleted!
              1 Reply Last reply
              0
              • K Offline
                K Offline
                Kent-Dorfman
                wrote 18 days ago last edited by
                #8

                I'm gonna speak in generalities here...the widgets in a Qt application form a tree structure where they have children and usually a single parent widget. When you change an entity in the tree, all of its children need to be updated as well, so the closer you are to the trunk, the more background processing it requires. All Qt programmers need to keep this in mind and subjectively manage their UI design to balance functionality with processing overhead. I think you need to work out some UI strategies to minimize the overhead of large scale child widget updates in your design.

                There are some experimental things to try but that's on you:

                1. horiz and vert scroll panel as parent of checkbox list
                2. custom widget design
                3. get rid of checkbox list in favor of a scrollable/collapsable tree-view
                4. add "submit" button to checkbox list and no doing any checkbox processing until the button is pressed
                1 Reply Last reply
                0
                • P Pl45m4
                  19 days ago

                  @hskoglund said in The window lags while resizing if there are too many checkboxes.:

                  consider moving the creation code out of your reiimplemented resizeEvent function

                  But @3xotic stated that it's not inside resizeEvent.

                  @3xotic Do you update something else on resize? Do you repaint manually somewhere?
                  Usually it should not lag when resizing that few widgets...

                  3 Offline
                  3 Offline
                  3xotic
                  wrote 18 days ago last edited by
                  #9

                  @Pl45m4 I do not update something else on resize and do not repaint manually somewhere (or so I think). Full code:

                  QApplication app(argc, argv);
                  QWidget window;
                  window.setWindowTitle("Adobe Leftovers Remover");
                  window.resize(1000, 800);
                  window.setFixedSize(window.size()); // Make the window non-resizable
                  
                  QVBoxLayout* mainLayout = new QVBoxLayout(&window);
                  QTabWidget* tabs = new QTabWidget;
                  
                  // Cleanup Tab
                  QWidget* cleanupTab = new QWidget;
                  QVBoxLayout* cleanupLayout = new QVBoxLayout(cleanupTab);
                  QHBoxLayout* groups = new QHBoxLayout;
                  
                  // Paths Group
                  QGroupBox* pathsGroup = new QGroupBox("Paths");
                  QVBoxLayout* pathsLayout = new QVBoxLayout;
                  QPushButton* selectAllPaths = new QPushButton("Select All Paths");
                  QPushButton* deselectAllPaths = new QPushButton("Deselect All Paths");
                  pathsLayout->addWidget(selectAllPaths);
                  pathsLayout->addWidget(deselectAllPaths);
                  QList<QCheckBox*> pathCheckboxes;
                  for (const QString& s : paths) {
                      auto cb = new QCheckBox(s);
                      pathCheckboxes.append(cb);
                      pathsLayout->addWidget(cb);
                  }
                  pathsLayout->addStretch();
                  pathsGroup->setLayout(pathsLayout);
                  
                  // Registry Keys Group
                  QGroupBox* registryGroup = new QGroupBox("Registry Keys");
                  QVBoxLayout* registryLayout = new QVBoxLayout;
                  QPushButton* selectAllRegistry = new QPushButton("Select All Keys");
                  QPushButton* deselectAllRegistry = new QPushButton("Deselect All Keys");
                  registryLayout->addWidget(selectAllRegistry);
                  registryLayout->addWidget(deselectAllRegistry);
                  QList<QCheckBox*> registryCheckboxes;
                  for (const QString& s : registryKeys) {
                      auto cb = new QCheckBox(s);
                      registryCheckboxes.append(cb);
                      registryLayout->addWidget(cb);
                  }
                  registryLayout->addStretch();
                  registryGroup->setLayout(registryLayout);
                  
                  groups->addWidget(pathsGroup);
                  groups->addWidget(registryGroup);
                  cleanupLayout->addLayout(groups);
                  QPushButton* deleteButton = new QPushButton("Delete Selected");
                  cleanupLayout->addWidget(deleteButton);
                  
                  // Logs Tab
                  QWidget* logsTab = new QWidget;
                  QVBoxLayout* logsLayout = new QVBoxLayout(logsTab);
                  QTextEdit* logView = new QTextEdit;
                  logView->setReadOnly(true);
                  logsLayout->addWidget(logView);
                  
                  tabs->addTab(cleanupTab, "Cleanup");
                  tabs->addTab(logsTab, "Logs");
                  
                  // Progress Bar
                  QProgressBar* progress = new QProgressBar;
                  progress->setValue(0);
                  mainLayout->addWidget(tabs);
                  mainLayout->addWidget(progress);
                  
                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote 15 days ago last edited by
                    #10

                    That code is not complete. It's missing both paths and registryKeys with dummy content to reproduce your issue.

                    Also, you are setting your window to a fixed size, this makes it non resizable.

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

                    3 1 Reply Last reply 14 days ago
                    0
                    • S SGaist
                      15 days ago

                      That code is not complete. It's missing both paths and registryKeys with dummy content to reproduce your issue.

                      Also, you are setting your window to a fixed size, this makes it non resizable.

                      3 Offline
                      3 Offline
                      3xotic
                      wrote 14 days ago last edited by
                      #11

                      @SGaist The header file with all its content:

                      #pragma once
                      #include <QStringList>
                      
                      inline const QStringList paths = {
                          "..."
                      };
                      
                      inline const QStringList registryKeys = {
                          "..."
                      };
                      

                      I know that the window is fixed in size, it is my temporal solution to this lag problem.

                      1 Reply Last reply
                      0

                      11/11

                      4 May 2025, 16:09

                      • Login

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