Results 1 to 14 of 14

Thread: How to put 2 Widgets in a MainWindow ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to put 2 Widgets in a MainWindow ?

    You can use something like this:
    Qt Code:
    1. QSizePolicy PlotPolicy = plot->sizePolicy();
    2. PlotPolicy.setVerticalStretch(1); //don't remember the exact "formula", try with 1
    3. plot->setSizePolicy(PlotPolicy);
    To copy to clipboard, switch view to plain text mode 
    if that doesn't do the right proportions, try this:
    Qt Code:
    1. QSizePolicy PlotPolicy = plot->sizePolicy();
    2. PlotPolicy.setVerticalStretch(2); //don't remember the exact "formula", so play with this values
    3. plot->setSizePolicy(PlotPolicy);
    4.  
    5. QSizePolicy DataPolicy = data->sizePolicy();
    6. DataPolicy.setVerticalStretch(1);
    7. plot->setSizePolicy(DataPolicy);
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2010
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to put 2 Widgets in a MainWindow ?

    Thanks Zlatomir !
    I used your second method and it works well !!!

    A last last question...is it possible to center my QTableWidget with that QVBoxLayout?
    I want to do that because when I resize my window manually with a mouse, the QTableWidget stays align at the left.
    Is there a similar function to
    Qt Code:
    1. QTableWidget::setAlignement(Qt::AlignCenter)
    To copy to clipboard, switch view to plain text mode 
    that exists ?
    I search the documentation, but couldn't find any easy way to do this

Similar Threads

  1. Replies: 5
    Last Post: 18th April 2010, 23:31
  2. resizing widgets when user resizes mainwindow
    By Mystical Groovy in forum Qt Programming
    Replies: 13
    Last Post: 21st December 2009, 00:03
  3. Replies: 2
    Last Post: 31st July 2009, 09:18
  4. Child Widgets In MainWindow
    By RY in forum Newbie
    Replies: 3
    Last Post: 4th October 2008, 08:39
  5. scrolled widgets containers in Mainwindow
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2006, 14:40

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.