Results 1 to 5 of 5

Thread: QHeaderView not resizing

  1. #1
    Join Date
    Apr 2008
    Posts
    21
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QHeaderView not resizing

    I am have been programming a tableview but I have a nagging problem for which I haven't been able to find any relevant posts.
    I have the following code:

    Qt Code:
    1. AttributeMapModel* model = new AttributeMapModel( canonical_fields, mapped_fields, user_fields ) ;
    2. AttributeDelegate* item_delegate = new AttributeDelegate;
    3. ui.AttributeMappingTable->setModel( model );
    4.  
    5. model->setHeaderData( 0, Qt::Horizontal, "User Fields", Qt::DisplayRole );
    6. model->setHeaderData( 1, Qt::Horizontal, "Rules", Qt::DisplayRole );
    7.  
    8. ui.AttributeMappingTable->setItemDelegate( item_delegate );
    9. ui.AttributeMappingTable->setEditTriggers( QAbstractItemView::CurrentChanged |
    10. QAbstractItemView::AnyKeyPressed );
    11.  
    12. ui.AttributeMappingTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
    13. ui.AttributeMappingTable->verticalHeader()->setResizeMode(QHeaderView::Stretch);
    14. ui.AttributeMappingTable->verticalHeader()->setStretchLastSection(true);
    To copy to clipboard, switch view to plain text mode 

    The horizontal header resizes as specified but the vertical header leaves space at the bottom after the last row which, if the mouse cursor enters it, causes an assert in QHeaderView::setSectionSize(). Q_ASSERT(visual != -1); This is a nuisance but the sizing is aethestically unpleasing itself. Am I missing something?

    Note: I am developing under Qt 4.0.1 I hope this doesn't require an upgrade.

  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: QHeaderView not resizing

    I'm not sure stretching the vertical header is supported... It wouldn't make much sense in most cases, I guess...

  3. #3
    Join Date
    Apr 2008
    Posts
    21
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QHeaderView not resizing

    Well, that may be right but then an assert (for vertical headers) should not be the result. One which you can't just ignore - at least I can't seem to get past it by pressing the ignore button. The assert (or others) keeps popping up. Could one, at least, crop the header to the rows?

  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: QHeaderView not resizing

    Quote Originally Posted by ericwny View Post
    Well, that may be right but then an assert (for vertical headers) should not be the result.
    Yes, that obviously true.

  5. #5
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QHeaderView not resizing

    Quote Originally Posted by ericwny View Post
    Note: I am developing under Qt 4.0.1 I hope this doesn't require an upgrade.
    Wow, that's pretty old... 3 years? Just be aware that the model view framework (and almost everything else in Qt for that matter) has been improved a lot since then. Not only new functionality was added but also lots of bug fixes were applied. Just curious, why do you resist updating? Are you one of those commercial customers whose license period ended?
    J-P Nurmi

Similar Threads

  1. QTableWidget column width and resizing
    By shooogun in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2008, 22:31
  2. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  3. Replies: 2
    Last Post: 14th August 2007, 15:16
  4. QMdiSubWindow resizing in 4.3
    By kalpa in forum Qt Programming
    Replies: 0
    Last Post: 4th June 2007, 13:39
  5. QHeaderView as a banner
    By mclark in forum Qt Programming
    Replies: 1
    Last Post: 21st March 2007, 19:28

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