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



  • 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


  • Qt Champions 2016

    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 ?



  • 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.



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



  • @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.


  • Qt Champions 2016

    @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?



  • @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).



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.