Results 1 to 4 of 4

Thread: Need to call QTableView::invalidate() before hiding columns

  1. #1
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Need to call QTableView::invalidate() before hiding columns

    I'm having trouble understanding why I need to call QTableView::invalidate() before I can hide columns in the view.

    Here m_proxy is a subclassed QSortFilterProxyModel with a reimplemented filterAcceptsRow and m_view is just QTableView.
    Qt Code:
    1. m_view->setColumnHidden(5, true);
    2. qDebug() << m_view->isColumnHidden(5);
    3.  
    4. m_proxy->invalidate();
    5.  
    6. m_view->setColumnHidden(5, true);
    7. qDebug() << m_view->isColumnHidden(5);
    To copy to clipboard, switch view to plain text mode 

    The above code returns:
    false
    true
    I am actually having trouble hiding columns elsewhere in my code which I how I stumbled on this curiosity.

    Thanks for any explanations!
    Last edited by brixton; 9th December 2010 at 18:58. Reason: reformatted to look better

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need to call QTableView::invalidate() before hiding columns

    It's likely you made some mistake in your reimplementation. And possibly the hiding is done some time later.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need to call QTableView::invalidate() before hiding columns

    Hi Wysota,
    In which reimplementation could there be a problem? I have reimplemented QAbstractItemModel. Could there be something there which is causing the problem?

    Hiding columns works perfectly after running the invalidate() but the previous calls to hideColumn(int) or setColumnHidden(int, bool) are lost.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Need to call QTableView::invalidate() before hiding columns

    I have no idea, I haven't seen your code.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Validator for QTableView columns
    By sasi in forum Qt Programming
    Replies: 0
    Last Post: 6th October 2009, 08:10
  2. Don't resize columns - QTableView
    By estanisgeyer in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2009, 16:59
  3. Different delegates to different Columns of QTableView.
    By kaushal_gaurav in forum Qt Programming
    Replies: 4
    Last Post: 6th August 2008, 09:17
  4. autoexpanding QTableView columns
    By ucntcme in forum Qt Programming
    Replies: 6
    Last Post: 11th March 2008, 09:28
  5. Moving columns/hiding columns in QTreeView
    By yogeshm02 in forum Qt Programming
    Replies: 4
    Last Post: 14th March 2007, 16:22

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
  •  
Qt is a trademark of The Qt Company.