Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    QPainter: Problem with drawing trajectory of a planet

    General and Desktop
    2
    3
    850
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      LeoQ last edited by

      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!
      1 Reply Last reply Reply Quote 0
      • A
        Arnaut last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • L
          LeoQ last edited by

          Ok. I'll try that. Thanks!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post