Results 1 to 3 of 3

Thread: Main Window size problem

  1. #1
    Join Date
    Sep 2009
    Location
    Belgrade, Serbia
    Posts
    40
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Main Window size problem

    I have the following problems. My application uses QStackedWidget as central widget. In QStackedWidget I have two widgets of different size that I alternate depending of what user choose.

    First bigger problem:

    Both widgets have height that is larger that the screen. Main Window automatically sets its size so that every thing fits but Main Window can't fit the screen and lower part are outside the screen. How can I set maximum size of my Main Window so it never gets bigger that what I set, and how can I put scroll bars so that user can scroll to areas that are not shown.

    I spent some time reading the documentation and trying this and that, I managed to set the Vertical scroll bar but it doesn't matter because main window is always too big and because of that you can't scroll all the way. I can't seem to figure out what I am doing wrong.

    Second problem:

    Since one widget in QStackedWidget is bigger (it has bigger width) it seems that the starting size of Main window is always set according to the bigger (wider) widget. Even when I set that the smaller widget as the starting one main window is to big for it and this smaller widget looks bad. How can I force main window to shrink when this narrower widget is set and that expand when the wider widget is set.

    In both problems I never what for main window to get bigger then some pre set size so that I avoid main window getting bigger than the screen. It would be nice if I could some how find out screens resolution and set maximum size of main window depending of the screen resolution. Also I would like both scroll bars to appear only if they are required but I can live with them being there all the time. Vertical one will always be nedded any way.

    I would appreciate any help. I am sure that answer to my problems is in documentation some where but I failed to find it and honestly I don't know where to look. Even if you tell me read about function A or read about class B it helps me.

    Thanks in advance.

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Main Window size problem

    You need a QScrollArea as the central widget..
    instead of setting the stackwidget as the centeral widget of mainwindow... just set a QScrollArea as the central widget and set the stackwidget as the child of QScrollArea..

  3. The following user says thank you to nish for this useful post:

    frenk_castle (20th December 2009)

  4. #3
    Join Date
    Sep 2009
    Location
    Belgrade, Serbia
    Posts
    40
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Main Window size problem

    I spent an hour last night trying and trying. Now I made it work in minutes. Thanks MrDeath.

Similar Threads

  1. How to show a wizard before the main window?
    By dcopeto in forum Qt Programming
    Replies: 3
    Last Post: 27th March 2009, 18:10
  2. set backgorund image on main window
    By narumi in forum Newbie
    Replies: 3
    Last Post: 17th February 2008, 01:06
  3. Main window with custom buttons ?
    By probine in forum Qt Programming
    Replies: 1
    Last Post: 22nd November 2006, 07:32
  4. Problem in porting Main window on linux
    By jyoti kumar in forum Qt Tools
    Replies: 2
    Last Post: 2nd June 2006, 09:35
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21

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.