Results 1 to 6 of 6

Thread: my programm crach with this code

  1. #1
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default my programm crach with this code

    hi all,
    can anybody tell me what is worng with this code:
    i have taken the code from this thread http://www.qtcentre.org/threads/4042...IntervalSymbol
    Qt Code:
    1. i'm trying to draw a curve where every point will be with errorbars. but wen i run the code the programm crash.
    2. messgraphFrame::messgraphFrame(QWidget *parent) :
    3. QFrame(parent),
    4. ui(new Ui::messgraphFrame)
    5. {
    6. ui->setupUi(this);
    7. QVector<QwtIntervalSample> samples(3);
    8. samples.append( QwtIntervalSample( 10 ,QwtInterval( 8, 12 )) );
    9. samples.append( QwtIntervalSample( 2,QwtInterval( 3, 7 )) );
    10. samples.append( QwtIntervalSample( 18,QwtInterval( 17, 20 )) );
    11.  
    12. QwtIntervalSymbol symbol( QwtIntervalSymbol::Bar );
    13. // QwtPlot *myPlot = new QwtPlot( NULL );
    14.  
    15. QwtPlotIntervalCurve *curve1 = new QwtPlotIntervalCurve("Curve 1");
    16. curve1->setSymbol( &symbol );
    17. curve1->setSamples( samples );
    18. curve1->attach(this->ui->qwtPlot);
    19. // curve1->setStyle( QwtPlotIntervalCurve::Tube );
    20. this->ui->qwtPlot->replot ();
    21.  
    22. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2011
    Posts
    14
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: my programm crach with this code

    Qt Code:
    1. QwtIntervalSymbol symbol( QwtIntervalSymbol::Bar );
    2. // QwtPlot *myPlot = new QwtPlot( NULL );
    3.  
    4. QwtPlotIntervalCurve *curve1 = new QwtPlotIntervalCurve("Curve 1");
    5. curve1->setSymbol( &symbol );
    To copy to clipboard, switch view to plain text mode 
    Try to use a pointer for symbol
    Qt Code:
    1. QwtIntervalSymbol* symbol = new QwtIntervalSymbol( QwtIntervalSymbol::Bar );
    2. // QwtPlot *myPlot = new QwtPlot( NULL );
    3.  
    4. QwtPlotIntervalCurve *curve1 = new QwtPlotIntervalCurve("Curve 1");
    5. curve1->setSymbol( symbol );
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: my programm crach with this code

    thank you for your reply but it did not work.
    i have found that the crash happens when i attach the curve to the plot.
    but tel now i did not understand why.

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: my programm crach with this code

    Build debug version and run it with debugger, after the crash post the backtrace.

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

    Default Re: my programm crach with this code

    Kangs hint is absolutely necessary - the symbol needs to be allocated by new. The rest of the code looks o.k.

    When you have fixed your code and your application still crashes, use your debugger and show the call stack.

    Uwe

  6. #6
    Join Date
    Jul 2010
    Posts
    10
    Qt products
    Qt4 Qt/Embedded Qt Jambi
    Platforms
    Unix/X11 Windows

    Default Re: my programm crach with this code

    thank you all it work

Similar Threads

  1. How can i add a ProgressIndicator to my programm?
    By Bong.Da.City in forum Qt Programming
    Replies: 1
    Last Post: 23rd August 2010, 21:36
  2. Why my programm is asking for libssl.so.7?
    By gboelter in forum Newbie
    Replies: 2
    Last Post: 29th September 2009, 12:23
  3. i want dynamic link my programm
    By coder1985 in forum Installation and Deployment
    Replies: 5
    Last Post: 19th November 2007, 10:59
  4. Pasting code from code tag in emacs
    By Gopala Krishna in forum General Discussion
    Replies: 0
    Last Post: 16th February 2007, 05:47

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.