QPainter: Problem with drawing trajectory of a planet



  • Hi! I'm a novice in Qt development, so sorry for asking dumb questions.
    I found some example in Qt that uses QPainter and altered it for my case. I tried to draw a trajectory of a planet which revolves around a "Sun" and I succeeded. The thing I'm stuck in is I don't know how to tell the program to clear the background in the beginning and then not to continue clearing it because I want to see the trajectory of the planet.

    1. I tried setAutofillBackground(true), but it doesn't suit me cause it clears background all the time.
    2. Then I tried
      painter.setBackgroundMode(Qt::TransparentMode);
      it does the same. If I turn clearing of background in both cases off , I get some messy imprint of my screen with different windows in it. Could you please give me an advice how to solve the problem?
      Thanks in advance!


  • You may try to set "Qt::WA_OpaquePaintEvent":http://developer.qt.nokia.com/doc/qt-4.8/qt.html#WidgetAttribute-enum attribute, but I suggest you paint the trajectory on a pixmap and then use the paint event to draw the pixmap on your widget.



  • Ok. I'll try that. Thanks!


Log in to reply
 

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