Results 1 to 2 of 2

Thread: Beginner layout question

  1. #1
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Beginner layout question

    I realize this is a beginner question but I still couldn't manage to get this working, so I'm resorting to the forum.

    I create a basic plot, not touching any of the sizing/resizing properties in its constructor.

    I then place it in a dock widget with a grid layout.

    The desired behavior: I want the plot always adjust its size to the dock widget. If it's small, it should shrink, if it's large it should expand.

    My code:
    Qt Code:
    1. myDockWidget = new QDockWidget(); // later will be a part of the main form (parentWidget()->parentWidget());
    2. myDockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
    3. myDockWidget->setWindowTitle("test dock");
    4. myGridLayout = new QGridLayout(myDockWidget);
    5.  
    6. QwtPlot *newPlot = new QwtPlot();
    7. newPlot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    8.  
    9. myDockWidget->setLayout(myGridLayout);
    10. newPlot->setParent(myDockWidget);
    11. myGridLayout->addWidget(newPlot, 0, 0, 1, 1);
    12.  
    13. myDockWidget->show();
    14. newPlot->show();
    To copy to clipboard, switch view to plain text mode 

    The way it behaves right now: the plot is at a fixed size, changing the size makes more of the plot visible but the plot stays the same size.

    Hope the code is independent enough.
    Last edited by frankiefrank; 9th March 2011 at 16:06.

  2. #2
    Join Date
    Dec 2010
    Location
    Israel
    Posts
    90
    Thanks
    59
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Beginner layout question

    Found this post and it helped me:
    http://www.qtcentre.org/threads/3932...to-QDockWidget

Similar Threads

  1. Layout question (Twitter-client-like app)
    By piotrj in forum Newbie
    Replies: 1
    Last Post: 10th January 2010, 09:47
  2. SQLite beginner question...
    By theMac in forum Newbie
    Replies: 3
    Last Post: 2nd September 2009, 01:01
  3. A question about adding to layout
    By Cruz in forum Qt Programming
    Replies: 1
    Last Post: 20th January 2009, 13:41
  4. simple thread layout question
    By mhoover in forum Qt Programming
    Replies: 1
    Last Post: 12th August 2006, 12:02
  5. Beginner C++ question
    By masoroso in forum General Programming
    Replies: 2
    Last Post: 19th April 2006, 15:15

Tags for this Thread

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.