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
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

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

    Make line 11 read:
    Qt Code:
    1. QVBoxLayout *layout = new QVBoxLayout(central);
    To copy to clipboard, switch view to plain text mode 
    and the warning should go away.

    The access violation is probably related to the buffer pointer; using it while it is NULL, accessing the "buffer+1" memory location, or trying to use the storage for the buffer pointer itself after it goes out of scope.

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

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

    Ok, eveything works now!!!

    just a last thing.. I want my plot to take 2/3 of the window andmy QTableWidget 1/3, is it possible to that with a QVBoxLayout ?

    Thanks for your help !!!

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

    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 

  4. #4
    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: 19th April 2010, 00:31
  2. resizing widgets when user resizes mainwindow
    By Mystical Groovy in forum Qt Programming
    Replies: 13
    Last Post: 21st December 2009, 01:03
  3. Replies: 2
    Last Post: 31st July 2009, 10:18
  4. Child Widgets In MainWindow
    By RY in forum Newbie
    Replies: 3
    Last Post: 4th October 2008, 09:39
  5. scrolled widgets containers in Mainwindow
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2006, 15: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.