Results 1 to 4 of 4

Thread: QTableView: strange behavior on a window maximization. How to fix that?

  1. #1
    Join Date
    Feb 2010
    Location
    Russia, Tatarstan, Naberezhnye Chelny
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question QTableView: strange behavior on a window maximization. How to fix that?

    Hello all.

    Seems like a bug...

    in constructor:
    Qt Code:
    1. ui->tableView->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    2. ui->tableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    3. ui->tableView->resizeColumnsToContents();
    4. ui->tableView->resizeRowsToContents();
    5.  
    6. connect(ui->tableView->horizontalHeader(), SIGNAL(sectionResized(int,int,int)),
    7. ui->tableView, SLOT(resizeRowsToContents()));
    To copy to clipboard, switch view to plain text mode 

    It's ok with that if you minimize the window/restore the state of the window.
    But when window is maximizing QTableView's row heights stay unaffected by event. Just ignore maximization...
    One strange thing: after maximization, row heights seem like resized for a normal window state. After returning from maximized state to normal, row heights seem like resized for a maximized window state, i.e. in other words resizing is looks like working with a latency equally to the previous window state. Seems like row height's resizing happens for the old WindowState, just before window became into the new state.
    Just one window's minimization repairs the situation but, till another maximization...
    Any workaround?
    Thanks.

    ---
    Qt 4.6.2
    WinXP SP2 Rus
    Qt SDK 2010.01
    Last edited by sarbash; 25th June 2010 at 14:11.

  2. #2
    Join Date
    Feb 2010
    Location
    Russia, Tatarstan, Naberezhnye Chelny
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTableView: strange behavior on a window maximization. How to fix that?

    okay, I've made a crutch by helping of a signal to workaround the window's maximization problem and posted the bug.

  3. #3
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QTableView: strange behavior on a window maximization. How to fix that?

    Changing geometry inside a constructor isn't recommended. The objects involved may not be fully constructed yet, while the layout managers require them to be in order to perform their job. It's normally better to perform this sort of task after the constructor is finished; the polish() routine may be of help here, or you can simply insert the resizing code somewhere after object construction in your own code.

  4. #4
    Join Date
    Feb 2010
    Location
    Russia, Tatarstan, Naberezhnye Chelny
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Lightbulb Re: QTableView: strange behavior on a window maximization. How to fix that?

    Agreed with you.
    But if you noticed that, constructor mainly was used for setting appropriate parameters. Sizing methods were applied to already prepared widgets (notice that setupUi() in the beginning). The problem is with reaction to window's maximization.
    But, it's ok now. I changed implementation because I've noticed significant performance degradation caused by
    Qt Code:
    1. setResizeMode(QHeaderView::ResizeToContents)
    To copy to clipboard, switch view to plain text mode 
    parameter.
    So, I've maded an appropriate signal and emit it in
    Qt Code:
    1. QMainWindow::changeEvent(QEvent *)
    To copy to clipboard, switch view to plain text mode 
    when necessary.
    Thank you for the participation.
    Last edited by sarbash; 29th June 2010 at 19:33. Reason: the problem was resolved

Similar Threads

  1. Strange behavior of QSqlTableModel
    By venomj in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2010, 03:29
  2. QComboBox strange behavior
    By Antebios in forum Newbie
    Replies: 2
    Last Post: 31st March 2009, 23:50
  3. Strange behavior of QSyntaxHighlighter in Qt3
    By lorebett in forum Qt Programming
    Replies: 1
    Last Post: 18th January 2009, 14:50
  4. Strange resize behavior
    By Lykurg in forum Newbie
    Replies: 3
    Last Post: 9th January 2007, 13:56
  5. scrollbars strange behavior
    By siniy in forum Qt Programming
    Replies: 6
    Last Post: 29th December 2006, 10:27

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.