Hi,
I have a simple problem... I'm adding a QwtPlot to a QMainWindow's central widget. I was wondering how to keep the QwtPlot as a square (maintaining aspect ratio) instead of stretching whenever the mainWindow stretches?
Thank you
Hi,
I have a simple problem... I'm adding a QwtPlot to a QMainWindow's central widget. I was wondering how to keep the QwtPlot as a square (maintaining aspect ratio) instead of stretching whenever the mainWindow stretches?
Thank you
Try QwtPlotRescaler from Qwt 5.2.
Uwe
jmsbc (11th April 2009)
And navigation example in the svn to learn how to use:
http://qwt.svn.sourceforge.net/viewv...34&view=markup
Hüseyin
Thanks for both of your help!
I have tried with this code:
This is taken fromQt Code:
QApplication& appref = app; QWidget window; window.setWindowTitle("..."); QwtPlotRescaler dataPlotRescaler(dataPlot.canvas()); window.connect(&dataPlot, SIGNAL(resized(double, double)), SLOT(showRatio(double, double))); QwtPlotCurve pc; Data data(d); pc.setData(data); pc.attach(&dataPlot); dataPlot.replot(); window.show(); appref.exec();To copy to clipboard, switch view to plain text mode
http://qwt.svn.sourceforge.net/viewv...34&view=markup
which doesn't seem to exist in the examples in https://qwt.svn.sourceforge.net/svnr...anches/qwt-5.2
The window that comes out is big, but the plot is small, in the top left corner.
I wished to bind the plot to the whole window and resize the plot when I resize the window first. And then maybe change the scale of the axes when the plot is resized.
rds,
Last edited by hml; 20th December 2009 at 22:14.
You need to add a layout for your window, where you add the plot widget ( or overload resizeEvent of widget and resize the plot manually ). But this is basic Qt and has not much to do with Qwt.
The rescaler is responsible for adjusting the scales, when the plot is resized, but it doesn't resize the plot.
Uwe
That is what i was suspecting. I am new to Qt as well.
Thanks very much for your answer,
Hi,
I am trying the same thing. I have inherited a class from QWTPlot and inside that I am calling
Qt Code:
QwtPlotRescaler rescaler(canvas());To copy to clipboard, switch view to plain text mode
Initially my plot X,Y axes have same range,0 to 1. But My data changes such that y axis range is -1 to 1 keeping x axis range 0 to 1, my aspect ratio is changed. I expected that the plot will become a rectangle of height=2*width. But it remains as a square and Y axis got shrunk. I need to dynamically change the Y axis range and need to maintain aspect ratio. What I need to do?
Bookmarks