Results 1 to 3 of 3

Thread: sizeHint() called for invisible rows

  1. #1
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default sizeHint() called for invisible rows

    I am working on a GUI to display log messages. For this I use a QTableView and a model that inherits from QAbstractTableModel. Each row in the QTableView represents one message. Due to the fact that some messages contain more text than others I have to resize the row height depending on the text length. For this I set the following:
    Qt Code:
    1. tableView->setWordWrap(true);
    2. tableView->setTextElideMode(Qt::ElideNone);
    3. tableView->verticalHeader()->setResizeMode(QHeaderView::ResizeToContents);
    To copy to clipboard, switch view to plain text mode 

    This works so far. The problem is a performance issue. If I insert one item the sizeHint role is called for all rows (and their columns) in the model - not only for the ones that are visible.
    Is there a way to get QT calculate sizes of visible rows only ?

    After inserting a new row into the model i called "reset()" in a first version. In my newest version I use "beginInsertRows()" and "endInsertRows()" instead but anyway the sizeHints of all model elements is requested by the view.

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: sizeHint() called for invisible rows

    What values you used for "beginInsertRows()" and "endInsertRows()" ??

  3. #3
    Join Date
    Mar 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: sizeHint() called for invisible rows

    I have to add some additional information to answer that. If a message arrives it is stored in a list "m_msgList" which has nothing to do with my QT model. Triggered via a QTimer a method "updateMsgView()" is periodically triggered. This method moves all entries of "m_msgList" to the "m_tableViewList" that is used in the QT Model.
    The following code fragment shows the part where the messages are moved to the model list. Even when "m_msgList" contains just one message the sizeHint role of all rows in the model is called.

    Qt Code:
    1. void updateMsgView(){
    2. ...
    3. //append the msgList to the tableViewList
    4. iter = m_tableViewList.end();
    5. beginInsertRows(QModelIndex(),m_tableViewList.size(),m_tableViewList.size() + m_msgList.size() -1);
    6. m_tableViewList.splice(iter,m_msgList);
    7. endInsertRows();
    8.  
    9. emit signalScrollToBottom();
    10. }
    To copy to clipboard, switch view to plain text mode 


    Due to the fact that the content of the messages does not change it should be possible to resize them one time (at the time they are moved to the model).

Similar Threads

  1. Invisible characters
    By Myrgy in forum Qt Programming
    Replies: 0
    Last Post: 1st March 2010, 12:37
  2. QTableWidget sizeHint Not Called
    By mbrusati in forum Qt Programming
    Replies: 0
    Last Post: 27th September 2008, 14:53
  3. debug -> invisible program
    By sarefo in forum Qwt
    Replies: 3
    Last Post: 16th January 2008, 13:21
  4. set QwtPlotCurve invisible
    By gyre in forum Qwt
    Replies: 2
    Last Post: 19th December 2007, 07:53
  5. [qt3]invisible toolbar
    By lszk in forum Qt Programming
    Replies: 2
    Last Post: 26th February 2006, 18:34

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.