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:
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);
}
TargetDisplay::TargetDisplay(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
d_plot = new RandomPlot(this);
QSizePolicy policy(QSizePolicy::Preferred, QSizePolicy::Preferred);
policy.setHeightForWidth(true);
d_plot->setSizePolicy(policy);
ui.horizontalLayout->insertWidget(0, d_plot);
}
To copy to clipboard, switch view to plain text mode
and then in my RandomPlot widget I have:
class RandomPlot: public IncrementalPlot
{
Q_OBJECT
public:
~RandomPlot();
int heightForWidth(int w) const {
return w;
}
}
class RandomPlot: public IncrementalPlot
{
Q_OBJECT
public:
RandomPlot(QWidget *parent);
~RandomPlot();
int heightForWidth(int w) const {
return w;
}
}
To copy to clipboard, switch view to plain text mode
But it's not remaining a square whenever the window stretches. What else do I need to include? Thank you.
-James
Bookmarks