Results 1 to 3 of 3

Thread: cloud of dots

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default cloud of dots

    Hi everybody
    It's my first project with QWT, i'm triyng to display a cloud of dots but the problem that only one point is displayed at (0, 0).

    Qt Code:
    1. #include <qapplication.h>
    2. #include <qwt_plot.h>
    3. #include <qwt_symbol.h>
    4. #include <qwt_plot_curve.h>
    5.  
    6. class Plot : public QwtPlot
    7. {
    8. public:
    9. Plot();
    10. ~Plot();
    11. private:
    12. QwtPlotCurve* Curve;
    13.  
    14. };
    15.  
    16. Plot::Plot():Curve(new QwtPlotCurve("MyCurve"))
    17. {
    18. double x[5]={25.0, 32.0, 45.0, 68.0, 91.0};
    19. double y[5]={25.0, 32.0, 45.0, 68.0, 91.0};
    20.  
    21. this->setAxisScale(xBottom,0.0, 150.0);
    22. this->setAxisScale(yLeft,0.0, 150.0);
    23.  
    24.  
    25. this->Curve->setRawSamples(x, y, 5);
    26. this->Curve->setPen(QPen(Qt::red));
    27.  
    28. this->Curve->setSymbol(new QwtSymbol(QwtSymbol::XCross, Qt::NoBrush,
    29. QPen(Qt::red), QSize(5, 5)));
    30.  
    31. this->Curve->setStyle(QwtPlotCurve::NoCurve);
    32.  
    33.  
    34. this->Curve->attach(this);
    35.  
    36.  
    37. }
    38.  
    39. Plot::~Plot()
    40. {
    41. delete Curve;
    42. }
    43.  
    44.  
    45.  
    46. int main(int argc, char **argv)
    47. {
    48. QApplication a(argc, argv);
    49.  
    50. Plot *p=new Plot();
    51. p->show();
    52.  
    53. return a.exec();
    54. }
    To copy to clipboard, switch view to plain text mode 

    any one can explain me what goes around ?

    Best regard

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

    Default Re: cloud of dots

    QwtPlotCurve::setRawSamples doesn't copy your arrays and those are from the stack !

    Better use QwtPlotCurve::setSamples or allocate your arrays on the heap with new or declare them as static or use a QVector.

    Uwe

  3. The following user says thank you to Uwe for this useful post:

    sergio486 (12th December 2010)

  4. #3
    Join Date
    Dec 2010
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: cloud of dots

    Great it seems to work !! Thank you Uwe

Similar Threads

  1. Dots in complex window mask
    By HapKoM in forum Qt Programming
    Replies: 2
    Last Post: 9th July 2010, 20:58
  2. Replies: 2
    Last Post: 6th July 2010, 14:21
  3. PDF export of Dots: bugs?
    By giusepped in forum Qwt
    Replies: 1
    Last Post: 14th June 2009, 14:52
  4. How to make three dots?
    By y.shan in forum Qt Programming
    Replies: 3
    Last Post: 11th February 2008, 10:29

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.