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.
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 5 Posters 311 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.
  • 3 Offline
    3 Offline
    3xotic
    wrote 10 days ago last edited by
    #1

    Hello!
    I made a window in Qt 6.9, the window has got two tabs one called "Selector" and the other "Logs".
    Selector:29 - 59.png
    Logs:
    29 - 60.png

    As you see the "Selector" has a lot of checkboxes and the "Logs" tab does not, well, when in the "Selector" tab the window lags while resizing but in the "Logs" tab the window resize is smooth.

    How can I make the resize smooth when in the "Selector" tab?

    Thanks!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote 10 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 10 days ago
      0
      • S SGaist
        10 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 10 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 10 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 10 days ago
          1
          • H hskoglund
            10 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 10 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 9 days ago
            0
            • H Offline
              H Offline
              hskoglund
              wrote 10 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 10 days ago last edited by
                #7
                This post is deleted!
                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kent-Dorfman
                  wrote 9 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
                    10 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 9 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 6 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 5 days ago
                      0
                      • S SGaist
                        6 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 5 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

                        8/11

                        30 Apr 2025, 05:02

                        • Login

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