Results 1 to 9 of 9

Thread: Stack overflow while resizing QwtScaleWidgets

  1. #1
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  3. #3
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Stack overflow while resizing QwtScaleWidgets

    Qt Code:
    1. #include <qwt_scale_widget.h>
    2. #include <qwt_scale_engine.h>
    3.  
    4. ScaleTest::ScaleTest(QWidget *parent, Qt::WFlags flags)
    5. : QMainWindow(parent, flags)
    6. {
    7. ui.setupUi(this);
    8.  
    9. QwtScaleWidget *scale = new QwtScaleWidget( QwtScaleDraw::BottomScale, this );
    10. QwtScaleWidget *scale2 = new QwtScaleWidget( QwtScaleDraw::BottomScale, this );
    11.  
    12.  
    13. // asigning the same values makes it crash
    14. // scale->setScaleDiv( NULL, engine->divideScale( 0, 100, 6, 10, 10 ) );
    15. // scale->setScaleDiv( NULL, engine->divideScale( 0, 100, 6, 10, 10 ) );
    16.  
    17. for( int i = 0; i < 100; i++ ){
    18. scale->setScaleDiv( NULL, engine->divideScale( 0, i, 6, 10, 10 ) );
    19. scale2->setScaleDiv( NULL, engine2->divideScale( 0, i, 6, 10, 10 ) );
    20. }
    21.  
    22. scale->show();
    23. }
    To copy to clipboard, switch view to plain text mode 

    I tried to make a simple example. There's no stack overflow there, but it still crashes.
    I'll check the stackoverflow again.

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Stack overflow while resizing QwtScaleWidgets

    No surprise, when you pass NULL instead of a valid transformation object.

    Uwe

  5. #5
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Stack overflow while resizing QwtScaleWidgets

    Thanks for the hint!

    But it still doesn't work. I tried the following and it still crashes.

    Qt Code:
    1.  
    2. for( int i = 0; i < 100; i++ ){
    3. scale->setScaleDiv( trans, engine->divideScale( 0, i, 6, 10, 10 ) );
    4. scale2->setScaleDiv( trans2, engine2->divideScale( 0, i, 6, 10, 10 ) );
    5. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Stack overflow while resizing QwtScaleWidgets

    Qt Code:
    1. for( int i = 0; i < 100; i++ ){
    2.  
    3. // you can't reuse the transformation objects !
    4.  
    5. scale->setScaleDiv( trans, engine->divideScale( 0, i, 6, 10, 10 ) );
    6. scale2->setScaleDiv( trans2, engine2->divideScale( 0, i, 6, 10, 10 ) );
    7. }
    To copy to clipboard, switch view to plain text mode 

    HTH,
    Uwe

  7. #7
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Stack overflow while resizing QwtScaleWidgets

    Still doesn't work.
    I'll try to find a workaround for this to avoid the seperate scales.

  8. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,311
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Stack overflow while resizing QwtScaleWidgets

    Quote Originally Posted by Vashkoda View Post
    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

  9. #9
    Join Date
    Feb 2009
    Posts
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default 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!

Similar Threads

  1. QThread stack overflow when exiting
    By jakamph in forum Qt Programming
    Replies: 4
    Last Post: 11th May 2006, 17:56

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.