Results 1 to 3 of 3

Thread: setColumnHidden does not hide column

  1. #1
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default setColumnHidden does not hide column

    In my software I have a tableview with a model.
    While runtime the model changes. Sometimes I want to hide columns, but after I changed the model a third time it does not work anymore.

    Qt Code:
    1. void MonitorWindow::setColumnsHidden(bool hide){
    2. for (int i = 0; i < myTransducermodel->columnCount(); ++i){
    3. qDebug() << hide << i;
    4. ui->transducerTable->setColumnHidden(i, hide);
    5. qDebug() << "hidden?" << ui->transducerTable->isColumnHidden(i);
    6. }
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    The Debug says:
    true 0
    hidden? false
    true 1
    hidden? false
    true 2
    hidden? false
    true 3
    hidden? false
    ...

    Why is that? Do I miss something when I set a new model?

    Qt Code:
    1. myTransducermodel->clearColumns();
    2.  
    3. ....
    4.  
    5. ui->transducerTable->setModel(myTransducermodel);
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. void TransducerSetModel::clearColumns(){
    2. tableHeaders.clear();
    3. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: setColumnHidden does not hide column

    It is possible that the GUI is not updated, and the column hidden, until after the program reaches your event loop. You do not say if the column is actually hidden or what "does not work any more" actually means.

    Hiding columns in a view is unrelated to adding/removing columns in the model. As long as the model correctly announces the column changes then the view should follow automatically. Is this a custom model?

  3. #3
    Join Date
    Oct 2015
    Posts
    50
    Thanks
    4
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: setColumnHidden does not hide column

    Yes it is a custom model and when I look closer I see that the column is actually hidden (did not see that before because the software crashed while runtime). So my problem is that "isColumnHidden(i)" returns false although the column is hidden.

    I fixed the crash now but I still don't understand why this is happening

Similar Threads

  1. Replies: 1
    Last Post: 9th December 2015, 18:23
  2. Replies: 1
    Last Post: 20th November 2015, 09:12
  3. qtableview:one table hide Column,and other tables not
    By chenmo20074639 in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2014, 03:54
  4. Replies: 3
    Last Post: 9th October 2012, 02:12
  5. Replies: 3
    Last Post: 5th May 2011, 14:03

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.