How to paint a constellation mapping using Qt.



  • Trying to paint a constellation mapping using Qt.
    Basiclly, I need to paint a rectangular plane coordinate system, and some dynamicly produced points.
    x-coordinate and y-coordinate both range from -1.5 to +1.5.
    And the point in the system will be a complex number like: -0.245203354620380 + 0.289405396579750i

    I've tried the class QPainter. But I don't know how to paint points anytime and not eliminate the formal points.
    It's like I can only paint one point a time using QWidget::paintevent method...


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Doesn't QPainter::drawPoints fit ?



  • It fits.
    But what I want to do is to catch a data stream at anytime and draw the point the data gives me on the widget.
    How can I make it happen?

    [quote author="SGaist" date="1408432772"]Hi and welcome to devnet,

    Doesn't QPainter::drawPoints fit ?[/quote]



  • Now I'm using the QWidget::paintevent

    But it repaints the whole widget. How can I only update a new point and don't change other points?

    [quote author="SGaist" date="1408432772"]Hi and welcome to devnet,

    Doesn't QPainter::drawPoints fit ?[/quote]



  • IIRC you can give a region argument to the update method, which then triggers the paintEvent calling.


  • Lifetime Qt Champion

    There are several possibilities, keep a list of your points, update it and redraw them all. Use a QPixmap, draw each new point on it then just draw this pixmap in your widget.

    Or look at e.g. Qwt which provides facilities for that kind of drawing.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.