Results 1 to 4 of 4

Thread: Graphic by Qwt in a QGraphicsView

  1. #1
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4

    Default Graphic by Qwt in a QGraphicsView

    Hi all !

    I've got a big problem when coding a program. I wanna show a graphic in a QGraphicsView with Qwt which will show me some marks, but I can't. There's no bug, but nothing is showed :
    Qt Code:
    1. vector<int> x, y;
    2. QwtPlot *myPlot = new QwtPlot(QwtText("Graphique de notes"), this);
    3. QRect r = graphiqueNotes->rect(); // "graphiquesNotes" is a QGraphicsView on the window
    4. QPainter painter(this);
    5.  
    6. painter.setClipRect(r);
    7.  
    8. x.push_back(1); // Let's suppose that we have two marks : one 8 and one 15
    9. x.push_back(2);
    10. y.push_back(8);
    11. y.push_back(15);
    12.  
    13. xMap.setScaleInterval(0, (double)x.size() + 1);
    14. yMap.setScaleInterval(0, 20);
    15.  
    16. xMap.setPaintInterval(r.left(), r.right());
    17. yMap.setPaintInterval(r.top(), r.bottom());
    18.  
    19.  
    20. sym.setStyle(QwtSymbol::Cross);
    21. sym.setPen(QColor(Qt::black));
    22. sym.setSize(5);
    23. crv.setSymbol(sym);
    24. crv.setPen(QColor(Qt::darkGreen));
    25. crv.setStyle(QwtPlotCurve::Lines);
    26. crv.setRenderHint(QwtPlotItem::RenderAntialiased);
    27.  
    28. crv.setRawData(x.data(), y.data(), x.size());
    29. crv.attach(myPlot);
    30.  
    31. myPlot->replot();
    32.  
    33. crv.draw(&painter, xMap, yMap, r);
    To copy to clipboard, switch view to plain text mode 

    What do you think about this ? Can you compile and tell me if you see something ?

    Thank you very much.
    ChoCChoK.
    Last edited by ChoCChoK; 16th March 2011 at 14:22.

  2. #2
    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: Graphic by Qwt in a QGraphicsView

    Implement a QGraphicsItem and paint inside of YourGraphicsItem:aint().

    Uwe

  3. #3
    Join Date
    Mar 2011
    Posts
    2
    Qt products
    Qt4

    Default Re: Graphic by Qwt in a QGraphicsView

    Thank you very much for your help, Uwe, but I don't understand what QGraphicsItem to implement. It's a virtual class.

  4. #4
    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: Graphic by Qwt in a QGraphicsView

    Then better start with reading some books about Qt anf OO programming and ask in the newbie section of this forum - this is the right place, for very basic questions.

    Uwe

Similar Threads

  1. Creating a graphic timeline
    By kaushal_gaurav in forum Qt Programming
    Replies: 2
    Last Post: 26th November 2012, 13:03
  2. Tricky graphic effect
    By insideru in forum Qt Programming
    Replies: 2
    Last Post: 13th August 2010, 02:11
  3. Reshape graphic items
    By jsmith in forum Qt Programming
    Replies: 3
    Last Post: 31st July 2009, 07:46
  4. Graphic evaluation
    By jd in forum Qt Programming
    Replies: 3
    Last Post: 7th February 2008, 14:46

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.