Results 1 to 6 of 6

Thread: Update to 4.4.2: cornerWidget functionality changed

  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Update to 4.4.2: cornerWidget functionality changed

    I've recently updated my Qt installation from 4.3.4 to 4.4.2.

    I've been experimenting with Qt's Model/View code using QTableView. A sample app I've been using, when compiled under 4.4.2 behaves differently than when using 4.3.4. Clicking on the cornerWidget of the table's headerView selects all cells in the table as expected, but Ctrl-click does not deselect as it did in 4.3.4, in fact it appears to do nothing.

    I'm not calling setSelectionMode() (although I have tried calling it using ExtendedSelection but this had no effect).

    My use of QHeaderView is as follows:
    Qt Code:
    1. // Set properties in the column headers
    2. QHeaderView* m_pColHdrView = horizontalHeader();
    3. m_pColHdrView->setHighlightSections( false );
    4. m_pColHdrView->setMovable( false );
    5. m_pColHdrView->setDefaultAlignment( Qt::AlignCenter );
    6. m_pColHdrView->setSortIndicator( 1, Qt::DescendingOrder );
    7. m_pColHdrView->setSortIndicatorShown( true );
    8. m_pColHdrView->setStretchLastSection( false );
    9.  
    10. // Set properties in the row headers
    11. QHeaderView* rowHdrView = verticalHeader();
    12. rowHdrView->setMovable( false );
    13. rowHdrView->setResizeMode( QHeaderView::Custom );
    14. rowHdrView->setClickable( true );
    To copy to clipboard, switch view to plain text mode 
    I suspect, as has happened before when switching to a new version of Qt, that I have uncovered some defect in my code that just happened to work before. Any ideas about what may cause the cornerWidget of a QTableView or QTableWidget to behave differently in this situation?

  2. #2
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Update to 4.4.2: cornerWidget functionality changed

    I now believe this is a Qt 4.4.2 issue. A mouse press on the corner widget selects all items in both versions but Ctrl mouse press unselects all only in 4.3.4. The following code displays this problem:

    Qt Code:
    1. #include <QApplication>
    2. #include <QTableView>
    3. #include <QStandardItemModel>
    4.  
    5. int main( int argc, char **argv )
    6. {
    7. QApplication app( argc, argv );
    8.  
    9. QTableView *table = new QTableView();
    10.  
    11. QStandardItemModel model( 5, 2 );
    12. for( int r=0; r<5; r++ )
    13. {
    14. for( int c=0; c<2; c++)
    15. {
    16. QStandardItem *item =
    17. new QStandardItem( QString("Row:%0, Column:%1").arg(r).arg(c) );
    18.  
    19. model.setItem(r, c, item);
    20. }
    21. }
    22.  
    23. table->setModel( &model );
    24. table->show();
    25.  
    26. return app.exec();
    27. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Update to 4.4.2: cornerWidget functionality changed

    I reported this as a bug to the Trolls but they said they won't fix it because it was an "intended behavior change".

    That being the case, how is one supposed to unselect all?

    Is there a way to ask them this directly?

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

    Default Re: Update to 4.4.2: cornerWidget functionality changed

    Apply an event filter on the header and catch that mouse press so that you can handle it yourself if you need it.

  5. The following user says thank you to wysota for this useful post:

    mclark (20th November 2008)

  6. #5
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Update to 4.4.2: cornerWidget functionality changed

    Quote Originally Posted by wysota View Post
    Apply an event filter on the header and catch that mouse press so that you can handle it yourself if you need it.
    If I trap the mouse press I'll use QTableWidget::clearSelection(), correct?

    I guess I'm just lazy and want Qt to do it for me like they used to.

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

    Default Re: Update to 4.4.2: cornerWidget functionality changed

    You can use whatever you want... QItemSelectionModel::clear() is a good candidate as well.

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.