Results 1 to 12 of 12

Thread: How to change QMainWindow size at runtime?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: How to change QMainWindow size at runtime?

    Quote Originally Posted by myfifth View Post
    What layout should be assinged to central frame?
    It depends on the contents of the frame. If it has no contents then layout is not required but you need to manually fix the size of the frame to something constant using QWidget::setFixedSize.

    As far as I known, QMainWindow has its default layout management, why did you say that it's not inside a layout?
    A layout of a widget is inside the widget not outside it. The main window is a floating window so it's not "in" a layout (as it would need to have a parent).

    Could you please explain it little more or refer me to something to read?
    Size policy is a set of rules that are used by a layout controlling the current widget to determine how much space to give to each widget controlled by the layout. Layout controlls the widgets that are in the layout, not the one the layout is in (the parent). If a particular widget (like your main window) is not part of some layout, its size policy and its size hint are ignored. The exception is that size hint of a window is used to determine the initial size of this window.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Jan 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to change QMainWindow size at runtime?

    @wysota

    I'm now much more clear.
    Layout in a widget is used to control layouting of its children, and size policy defines how layout works.

    In my case, I should care about how to design frame layout instead of main window. I'll try it later.

    Thanks a lot.

  3. #3
    Join Date
    Jan 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to change QMainWindow size at runtime?

    @wysota
    Sorry for late reply.
    setFixedSize and setSizeConstraint worked quite well. I simply set both of them to expected values, finally it rocked.

    Really thx.

Similar Threads

  1. QToolbar - change icon at runtime ?
    By pl01 in forum Qt Programming
    Replies: 6
    Last Post: 18th November 2010, 17:51
  2. Change QPixmap image at runtime
    By Qt Coder in forum Qt Programming
    Replies: 12
    Last Post: 30th March 2009, 12:37
  3. Replies: 2
    Last Post: 23rd March 2009, 17:26
  4. how change language at runtime?
    By mattia in forum Newbie
    Replies: 3
    Last Post: 14th November 2007, 18:36
  5. change font size and button size of QMessageBox
    By nass in forum Qt Programming
    Replies: 6
    Last Post: 13th September 2006, 19:16

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.