Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [Composing images] What is the best way to compose static and dynamic content in a drawing?
Forum Updated to NodeBB v4.3 + New Features

[Composing images] What is the best way to compose static and dynamic content in a drawing?

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.2k Views 3 Watching
  • 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.
  • NWeyandN Offline
    NWeyandN Offline
    NWeyand
    wrote on last edited by
    #1

    Until now, I have been drawing on a QWidget using QPainter. What I am basically drawing is similar to the Qt Analog Clock Example in that there are static parts of my drawing (like the markers indicating hours and minutes – these static parts don't change at all over the course of the program execution), as well as dynamic parts (like the clock faces – just changing much faster than those. Imagine a third hand in the linked to example displaying the seconds for a good facsimile).

    Is there any fancy way to make something similar to the linked to example, but instead of redrawing everything on each refresh to only redraw certain parts? Is there maybe a way of composing images of several layers so that one could update each (partially transparent) layer at its own pace?

    kshegunovK 1 Reply Last reply
    0
    • NWeyandN NWeyand

      Until now, I have been drawing on a QWidget using QPainter. What I am basically drawing is similar to the Qt Analog Clock Example in that there are static parts of my drawing (like the markers indicating hours and minutes – these static parts don't change at all over the course of the program execution), as well as dynamic parts (like the clock faces – just changing much faster than those. Imagine a third hand in the linked to example displaying the seconds for a good facsimile).

      Is there any fancy way to make something similar to the linked to example, but instead of redrawing everything on each refresh to only redraw certain parts? Is there maybe a way of composing images of several layers so that one could update each (partially transparent) layer at its own pace?

      kshegunovK Offline
      kshegunovK Offline
      kshegunov
      Moderators
      wrote on last edited by kshegunov
      #2

      @NWeyand said in [Composing images] What is the best way to compose static and dynamic content in a drawing?:

      Is there any fancy way to make something similar to the linked to example, but instead of redrawing everything on each refresh to only redraw certain parts?

      You can cache all of the static parts. Draw them once and keep the image; then draw the dynamic content on each tick.

      Is there maybe a way of composing images of several layers so that one could update each (partially transparent) layer at its own pace?

      Yes, see the composition modes' docs and examples.

      Read and abide by the Qt Code of Conduct

      1 Reply Last reply
      1
      • NWeyandN Offline
        NWeyandN Offline
        NWeyand
        wrote on last edited by NWeyand
        #3

        After some more research on this topic, I have decided to switch to a solution using several QPixMaps, all of which are initialized at startup and only some of which are updated at a later time. These are handled as QGraphicsPixmapItem and composed in a QGraphicsScene. This also covers nicely for the fact, that I was moving one of the to be composed pictures around on each redraw.

        Any comments / pitfalls I need to be aware of?

        kshegunovK 1 Reply Last reply
        0
        • NWeyandN NWeyand

          After some more research on this topic, I have decided to switch to a solution using several QPixMaps, all of which are initialized at startup and only some of which are updated at a later time. These are handled as QGraphicsPixmapItem and composed in a QGraphicsScene. This also covers nicely for the fact, that I was moving one of the to be composed pictures around on each redraw.

          Any comments / pitfalls I need to be aware of?

          kshegunovK Offline
          kshegunovK Offline
          kshegunov
          Moderators
          wrote on last edited by kshegunov
          #4

          Not really, no. It sounds like a good plan. Only thing that might be considered a "pitfall" is probably if you want to thread the painting later, then pixmaps aren't suitable, but I suppose you could switch to QImage rather easily if that requirement arises.

          PS.
          You might also want to try QML and QtQuick, which supposedly performs much better than the graphics view framework.

          Cheers!

          Read and abide by the Qt Code of Conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved