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. Hiding the Window with a table widget hangs the Application for few seconds
Qt 6.11 is out! See what's new in the release blog

Hiding the Window with a table widget hangs the Application for few seconds

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 3 Posters 1.6k Views 1 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.
  • ic3dra9onI Offline
    ic3dra9onI Offline
    ic3dra9on
    wrote on last edited by
    #1

    Hi,

    I have a menu item in the mainwindow which when clicked would bring up another window(QWidget) with a table widget(QTableWidget) in it. The table has around 30000 rows and 12 columns. When the new window is closed, I call hide() in the closeEvent() method. The following behavior is observed.

    • Scroll the Table in the new window to the last row and close. hide() is called and Everything is fine
    • Scroll bar is at top and window is closed. hide() is called again but this time, it hangs the whole application for few seconds and then hides the new window.

    Is this an expected an behavior ?

    Thanks

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

      Hi and welcome
      Are you sure its just not still scrolling up?
      Have you tried scrolling to top and then wait a moment.
      Then see ?

      ic3dra9onI 1 Reply Last reply
      0
      • miclandM Offline
        miclandM Offline
        micland
        wrote on last edited by
        #3

        I think that the table is still calculating the best width for all columns.
        You could try if this problem still exists when you keep the table empty or specify a fixed width for each column.

        ic3dra9onI 1 Reply Last reply
        2
        • miclandM micland

          I think that the table is still calculating the best width for all columns.
          You could try if this problem still exists when you keep the table empty or specify a fixed width for each column.

          ic3dra9onI Offline
          ic3dra9onI Offline
          ic3dra9on
          wrote on last edited by
          #4

          @micland
          I am using horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents ) in the QTableWidget constructor. Can this be a possible cause ?

          miclandM 1 Reply Last reply
          0
          • mrjjM mrjj

            Hi and welcome
            Are you sure its just not still scrolling up?
            Have you tried scrolling to top and then wait a moment.
            Then see ?

            ic3dra9onI Offline
            ic3dra9onI Offline
            ic3dra9on
            wrote on last edited by
            #5

            @mrjj
            When the scroll is at bottom, it stays at bottom on the next call to the window from the menu item on mainwindow. If I close the window now, it closes instantly. But, if I move it to top and close the window, the application hangs again.

            mrjjM 1 Reply Last reply
            0
            • ic3dra9onI ic3dra9on

              @mrjj
              When the scroll is at bottom, it stays at bottom on the next call to the window from the menu item on mainwindow. If I close the window now, it closes instantly. But, if I move it to top and close the window, the application hangs again.

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

              @ic3dra9on said:

              But, if I move it to top and close the window, the application hangs again.

              Also if you wait a moment before u press close?

              1 Reply Last reply
              0
              • ic3dra9onI ic3dra9on

                @micland
                I am using horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents ) in the QTableWidget constructor. Can this be a possible cause ?

                miclandM Offline
                miclandM Offline
                micland
                wrote on last edited by
                #7

                @ic3dra9on said:

                I am using horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents ) in the QTableWidget constructor. Can this be a possible cause ?

                Yes that could be the problem. I think it's calculating the width of ALL cells (not just the visible cells) to calculate the best column width. And this might take some seconds for 360.000 cells...
                You can speed up this step by specifying a fixed width per column. If I'm right you can combine this ResizeMode with some fixed row widths: tableView->setColumnWidth(colIdx, widthInPx); (if you can define a fixed width at least of some columns to reduce the amount of cells to inspect).

                ic3dra9onI 1 Reply Last reply
                2
                • miclandM micland

                  @ic3dra9on said:

                  I am using horizontalHeader()->setResizeMode( QHeaderView::ResizeToContents ) in the QTableWidget constructor. Can this be a possible cause ?

                  Yes that could be the problem. I think it's calculating the width of ALL cells (not just the visible cells) to calculate the best column width. And this might take some seconds for 360.000 cells...
                  You can speed up this step by specifying a fixed width per column. If I'm right you can combine this ResizeMode with some fixed row widths: tableView->setColumnWidth(colIdx, widthInPx); (if you can define a fixed width at least of some columns to reduce the amount of cells to inspect).

                  ic3dra9onI Offline
                  ic3dra9onI Offline
                  ic3dra9on
                  wrote on last edited by
                  #8

                  @micland
                  You guessed it right man. That is the issue. Thanks a lot for your help :)

                  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