Results 1 to 2 of 2

Thread: Invalidating layout

  1. #1
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Invalidating layout

    My question is related to the thread http://www.qtcentre.org/forum/f-qt-p...ues-14764.html that discusses disabling scroll bars in the QTableView. When a user resizes a column or a row I'd like the scroll bars also to not appear. It seems that all I need to do is to invalidate the layout of my table view. I modified the code shown in the post above by adding a slot that calls setFixedSize() on a sub-class of QTableView and connecting sectionResized signals from vertical and horizontal headers to my new slot:

    Qt Code:
    1. MyTableView::MyTableView(QWidget* parent)
    2. : QTableView(parent)
    3. {
    4. QObject::connect(verticalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(headerResized(int, int, int)));
    5. QObject::connect(horizontalHeader(), SIGNAL(sectionResized(int, int, int)), this, SLOT(headerResized(int, int, int)));
    6. }
    7.  
    8. void MyTableView::headerResized(int, int, int)
    9. {
    10. setFixedSize(minimumSizeHint());
    11. }
    To copy to clipboard, switch view to plain text mode 

    This code invalidates the layout but the documentation of setFixedSize says that

    This will override the default size constraints set by QLayout.
    Would it be possible in Qt to invalidate the layout without overriding the default size constraints?

    Thanks in advance,
    Yuri

  2. #2
    Join Date
    Sep 2008
    Posts
    60
    Thanks
    8
    Thanked 10 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Invalidating layout

    It seems that in this case QWidget::updateGeomentry() is the right method to call instead of QWidget::setFixedSize(). Sorry, I should have spent more time looking through the docs.

    Yuri

Similar Threads

  1. changing layout of a widget
    By mikro in forum Qt Programming
    Replies: 10
    Last Post: 4th August 2009, 21:21
  2. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 18:11
  3. Replies: 2
    Last Post: 30th April 2007, 13:11
  4. Resizing problems when applying a layout
    By JimBrown in forum Newbie
    Replies: 1
    Last Post: 21st February 2007, 23:54
  5. "dynamic" layout
    By hulk in forum Qt Programming
    Replies: 2
    Last Post: 9th May 2006, 08:16

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.