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:
myDockWidget
= new QDockWidget();
// later will be a part of the main form (parentWidget()->parentWidget());myDockWidget
->setFeatures
(QDockWidget::AllDockWidgetFeatures);
myDockWidget->setWindowTitle("test dock");
myDockWidget->setLayout(myGridLayout);
newPlot->setParent(myDockWidget);
myGridLayout->addWidget(newPlot, 0, 0, 1, 1);
myDockWidget->show();
newPlot->show();
myDockWidget = new QDockWidget(); // later will be a part of the main form (parentWidget()->parentWidget());
myDockWidget->setFeatures(QDockWidget::AllDockWidgetFeatures);
myDockWidget->setWindowTitle("test dock");
myGridLayout = new QGridLayout(myDockWidget);
QwtPlot *newPlot = new QwtPlot();
newPlot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
myDockWidget->setLayout(myGridLayout);
newPlot->setParent(myDockWidget);
myGridLayout->addWidget(newPlot, 0, 0, 1, 1);
myDockWidget->show();
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.
Bookmarks