Stack overflow while resizing QwtScaleWidgets
hi,
I need seperate scale widgets that zoom in and out according to the plots between them. Constructing them and getting the needed values is not the problem. But the only way to resize a QwtScaleWidget seems to be QwtScaleWidget::setScaleDiv(). So I construct a QwtLinearScaleEngine and via QwtLinearScaleEngine::divideScale(..) get a scaleDiv and put it into my scale widget.
First problem is that when I append a scaleDiv with the same values as the last one, I get an index out of range. But that can be avoided by checking the values first.
But the problem I can't solve is that if you change the values numerous times with QwtScaleWidget::setScaleDiv() it crashes with a stackoverflow.
Any suggestions? Or is there another way to scale a QwtScaleWidget?
Thanks!
Re: Stack overflow while resizing QwtScaleWidgets
If you can prepare some demo code, that can be built on Linux I will have a look at it. If not start your debugger and post the stack.
What are the values in your QwtScaleDiv objects, when it crashes ?
Uwe
Re: Stack overflow while resizing QwtScaleWidgets
Code:
#include <qwt_scale_widget.h>
#include <qwt_scale_engine.h>
ScaleTest
::ScaleTest(QWidget *parent, Qt
::WFlags flags
){
ui.setupUi(this);
// asigning the same values makes it crash
// scale->setScaleDiv( NULL, engine->divideScale( 0, 100, 6, 10, 10 ) );
// scale->setScaleDiv( NULL, engine->divideScale( 0, 100, 6, 10, 10 ) );
for( int i = 0; i < 100; i++ ){
scale->setScaleDiv( NULL, engine->divideScale( 0, i, 6, 10, 10 ) );
scale2->setScaleDiv( NULL, engine2->divideScale( 0, i, 6, 10, 10 ) );
}
scale->show();
}
I tried to make a simple example. There's no stack overflow there, but it still crashes.
I'll check the stackoverflow again.
Re: Stack overflow while resizing QwtScaleWidgets
No surprise, when you pass NULL instead of a valid transformation object.
Uwe
Re: Stack overflow while resizing QwtScaleWidgets
Thanks for the hint!
But it still doesn't work. I tried the following and it still crashes.
Code:
for( int i = 0; i < 100; i++ ){
scale->setScaleDiv( trans, engine->divideScale( 0, i, 6, 10, 10 ) );
scale2->setScaleDiv( trans2, engine2->divideScale( 0, i, 6, 10, 10 ) );
}
Re: Stack overflow while resizing QwtScaleWidgets
Code:
for( int i = 0; i < 100; i++ ){
// you can't reuse the transformation objects !
scale->setScaleDiv( trans, engine->divideScale( 0, i, 6, 10, 10 ) );
scale2->setScaleDiv( trans2, engine2->divideScale( 0, i, 6, 10, 10 ) );
}
HTH,
Uwe
Re: Stack overflow while resizing QwtScaleWidgets
Still doesn't work.
I'll try to find a workaround for this to avoid the seperate scales.
Re: Stack overflow while resizing QwtScaleWidgets
Quote:
Originally Posted by
Vashkoda
Still doesn't work.
What does this mean ?
[ ] The same crashes are still there
[ ] You are running into other crashes.
[ ] The crashes are gone, but you are not able to implement your idea with external scale widgets.
Uwe
Re: Stack overflow while resizing QwtScaleWidgets
It works!
I use Perforce SVN and I found that Perforce has qt*.dll's in its path. Of course different versions of Qt than I have. Removing the Perforce entry from the system path solved a lot of oddities.
Thanks for the help, Uwe!