Could someone post me solution for such bug?
this is only difference between good / bad look.
Code is simple - new Plot
insert legend
other things arn't important ( bug still exist with commented rest of code )
qwt: 5.2.1
qt 4.5
compiler: vc2008
Printable View
Could someone post me solution for such bug?
this is only difference between good / bad look.
Code is simple - new Plot
insert legend
other things arn't important ( bug still exist with commented rest of code )
qwt: 5.2.1
qt 4.5
compiler: vc2008
Hard to say what is wrong - but it looks like the layout has not been recalculated and the left scale widget is smaller than its scale.
Guess you insert your legend later - when the plot is already visible - and the problem is gone, when you call QwtPlot::updateLayout() or manually resize the plot with the mouse.
Please post your code demonstrating the bug.
Uwe
As I said there's no need more code - QwtPlot is create by Designer and in parent constructor ( after setupUI ) I call new legend, insertLegend
call updateLayout() in this place replot or similiar is without effect.
of course after display plot and resize it bad effect is gone - but it's not a solution, I have to show it fine in first view.
Some part of solution could be setbut with such set QwtPlot get bigger ( about legend size ) and mess other view with grid layout which holds Widgets with plots.Code:
qwtPlot->setAutoReplot();
setAutoReplot to true - false - don't work
Is there other ( better ) function to recalculate qwtPlot ??
Ok I found workaround by call updateLayout but just before display main widget
The code you have posted is used in many applications ( f.e Qwt examples ) without any problems - so there has to be something special in your code. But when you insist on not posting code ...
Uwe
The code you have posted is used in many applications ( f.e Qwt examples ) without any problems - so there has to be something special in your code. But when you insist on not posting code ...
Uwe
If example is simple the same code may work fine and with other code it could crash - but bug is in that code.
I think I 've got it becauce i put QwtPlot into QDockWidget and that in QGridLayout
if you really need code is something like that:
if there is legend q probably catch some event inproperlyCode:
dw->setWidget(q) l->addWidget(dw)
I have the same problem as darkshu. Actually it is really strange because I have a several plots in a few widgets. All the widgets look ok except one. And I can't understand what is wrong (unusual) with that one.
Does anybody know why the problem can appear and how to fix it?
The same answer: if you want to look into this, send me a small compilable application demonstrating the problem.
Uwe
I found where was a problem but I didn't understand why it was so.
Here is a demostration example:
A Qwt plot with a legend
Code:
public: SimplePlot (); }; SimplePlot::SimplePlot() { } }
A code with a bug:
Code:
SimplePlot * plot = new SimplePlot (plotWidget); // a problem //SimplePlot * plot = new SimplePlot; // no problems plotLayout->addWidget(plot); plotWidget->setLayout(plotLayout); tabWidget->insertTab(1, plotWidget, "Plot"); tabWidget->setMinimumSize(400, 400); tabWidget->show();
P.S. if I firstly insert the "Plot" tab and secondly the "Test Label" tab everything also looks fine (even if I use a constructor with a parent widget)
When the plot is initially on a hidden tab it gets a polish request in a hidden state and the resize event later before it gets displayed ( what could be considered as a Qt bug ). In such a situation the plot layout gets calculated for the widget default size ( 100x30 ) with an invalid height for the vertical scales. The QwtPlot layout code can't handle this with the result, that can be seen on your screenshot.
To avoid this problem I set a default size of 200x200 in the constructor to have something valid, when the polish request is processed. Note, that you will never see the plot widget in its default size, as its size is always changed by your application layout before it gets visible.
The fix is in SVN ( 5.2 + trunk branches ). If you don't want to update your installed Qwt version you can simply do this in your application code:
Uwe