Results 1 to 1 of 1

Thread: QMainWindow size management

  1. #1
    Join Date
    Mar 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question QMainWindow size management

    Hi there,

    I was wondering how to prevent child widgets from changing the size of a QMainWindow while still allowing the user to freely change the size. I tried reimplementing the resizeEvent in class MainWindow which is derived from QMainWindow like follows:

    void
    MainWindow::resizeEvent( QResizeEvent *event )
    {
    if( !event->spontaneous() ) // not initiated by user
    {
    resize( event->oldSize() );
    updateGeometry();
    }
    }

    I verified that resize gets called. event()->oldSize() is indeed the size before the programmatic size change. However, the size of the window doesn't change. Using setGeometry() instead of resize() doesn't work either. The docs mention that calling resize() within resizeEvent() might cause an infinite recursion. From my observation this doesn't seem to be the case here. Any ideas how to solve this problem?

    Thanks,
    Chris

    P.S.: Just realized that the resize doesn't have any effect because the child widgets won't shrink any further, not even when trying to change the window size with the mouse. I guess I'll need to change their minimum size and size policy.
    Last edited by chrishipp; 6th March 2010 at 00:19.

Similar Threads

  1. QMainWindow -> centralWidget size
    By lalesculiviu in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2009, 09:40
  2. Replies: 2
    Last Post: 23rd March 2009, 17:26
  3. Shrink QMainWindow to Minimum Size
    By kloffy in forum Qt Programming
    Replies: 4
    Last Post: 17th February 2008, 17:54
  4. How to set QListWidget size MAX = QMainWindow ?
    By Kenneth in forum Qt Programming
    Replies: 3
    Last Post: 16th March 2007, 10:11
  5. Replies: 1
    Last Post: 9th February 2007, 09:41

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.