Maintaining square widget (plot)
Hi,
Is there a way to maintain QwtPlot's physical aspect ratio in a layout? Uwe, you suggested QwtPlotRescaler before, but now I need QwtPlot to look like a square widget instead of rectangle when the window stretches. Here's what I tried to do:
Code:
TargetDisplay
::TargetDisplay(QWidget *parent
){
ui.setupUi(this);
d_plot = new RandomPlot(this);
policy.setHeightForWidth(true);
d_plot->setSizePolicy(policy);
ui.horizontalLayout->insertWidget(0, d_plot);
}
and then in my RandomPlot widget I have:
Code:
class RandomPlot: public IncrementalPlot
{
Q_OBJECT
public:
~RandomPlot();
int heightForWidth(int w) const {
return w;
}
}
But it's not remaining a square whenever the window stretches. What else do I need to include? Thank you.
-James
Re: Maintaining square widget (plot)
Nevermind, I figured it out. Instead of adding d_plot directly to the horizontalLayout, I added it to QwtDynGridLayout first, and then added the layout to the horizontalLayout:
Code:
gLayout->addWidget(d_plot);
ui.horizontalLayout->insertLayout(0, gLayout);
Now I get a square