PDA

View Full Version : Axis problem with tiling QWTplots



dtakeshita
2nd December 2010, 13:40
Hello,

I use qwt-5.2.1. I want to make a grid of graphs and to put y-axis only in the graphs on the left column and put x-axis only in the graphs on the bottom row. A picture is attached to give the idea. I have done this with Qwtplot with enableAxis and QGridLayout. However, as one can see in the picture, the size of a plot window with axes becomes smaller than that witout axis. For example, the size of the top left graph is smaller than the one on the right.

Would there be a way to fix this without changing the code too much? If not, what is the best way to handle this?

Thanks a lot,

Daisuke

FelixB
2nd December 2010, 14:53
just an idea:


plotWithoutAxis->setWidth(plotWithAxis->canvas()->width())

dtakeshita
3rd December 2010, 10:07
Thank you for the reply. Would it be possible to get a width (or size) of a canvas? canvas()->width() doesn't seem to work and I can't find a relevant member function in the document on QwtPlotCanvas class.

Thanks,

daisuke

FelixB
3rd December 2010, 11:03
since QwtPlotCanvas) is inherited from QFrame, "int QFrame::frameWidth()" should do it...

Uwe
3rd December 2010, 12:08
You could calculate the additional space for the left/bottom axis from the sizeHints and try to adjust the stretch factors for the first row and last column of your grid layout with it.

But in the end better forget about the grid layout and reimplement the resize event of your container widget where you do setGeometry manually for all of your plot widgets.

Uwe

dtakeshita
3rd December 2010, 12:47
reimplement the resize event of your container widget where you do setGeometry manually for all of your plot widgets.
Uwe

I don't have a clear idea how one could do this since I don't have a lot of eypereince with Qwt. I would appreciate if you could give me more detailed explanation.

Uwe
3rd December 2010, 13:02
I don't have a clear idea how one could do this since I don't have a lot of eypereince with Qwt. I would appreciate if you could give me more detailed explanation.

This is Qt ( no Qwt ) know how. Overload the resizeEvent of the widget, where you have your QGridLayout and lay out your plot widgets manually using QWidget::setGeometry.

Uwe

dtakeshita
6th December 2010, 11:00
This is Qt ( no Qwt ) know how. Overload the resizeEvent of the widget, where you have your QGridLayout and lay out your plot widgets manually using QWidget::setGeometry.

Uwe
Thank you for educating me! I will look into this option.