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. QGraphicsScene with custom QPainter
Forum Updated to NodeBB v4.3 + New Features

QGraphicsScene with custom QPainter

Scheduled Pinned Locked Moved Solved General and Desktop
qpainterqpaintengine
12 Posts 2 Posters 5.8k Views 1 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.
  • mrjjM mrjj

    @Joel-Bodenmann said:

    Hi
    How do your own algorithms for rendering rectangles etc work right now?

    I was wondering if they could render to a QPixmap , you could cheat that way and
    just display images in scene. (maybe)

    Making a custom QPainter will be complex as you mention your self, not all are virtual.

    Joel BodenmannJ Offline
    Joel BodenmannJ Offline
    Joel Bodenmann
    wrote on last edited by Joel Bodenmann
    #3

    @mrjj Thank you for your reply!

    Our rendering algorithms are optimized to use whatever hardware acceleration is available on the target system. If we want to draw a rectangle and the target hardware provides hardware acceleration for rectangle drawing we will use that. It's very similar to how QPainter/QPaintEngine works. After all the library was inspired by Qt ;)
    Anyway, all our rendering algorithms have a fallback to basic drawPixel(). This means that the only interface we need to Qt is the ability to manually draw pixels. If we can use hardware acceleration routines for rendering rectangles and so on we will be happily using them, but if that's not (easily) possible, we can work with drawPixel() only without any problem.

    Industrial process automation software: https://simulton.com
    Embedded Graphics & GUI library: https://ugfx.io

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #4

      Ok. Im asking
      as in a GUI Designer, often the needed refresh rate is not very high so
      I wondering if you could hook up your algorithms with
      http://doc.qt.io/qt-5.5/qimage.html#scanLine
      and that way provide exact preview of what he will get.

      1 Reply Last reply
      0
      • Joel BodenmannJ Offline
        Joel BodenmannJ Offline
        Joel Bodenmann
        wrote on last edited by Joel Bodenmann
        #5

        If I understand you correctly I would maintain my own framebuffer to which I render using my algorithms (which is very easy for me) and then create a QImage that spans the entire display area (the entire scene) and copy the framebuffer to the QImage?
        You linked to the QImage::scanLine() method but I don't know how that helps in my case. If anything I would need to provide a scanLine() function to my own framebuffer which the QGraphiscScene can use, no?

        Another issue I have is that I still need to use QGraphicsItems as I need to be able to move the items in the QGraphisScene, and use other features like that.
        Maybe it would be possible that I maintain one framebuffer per QGraphicsItem myself and then dump that framebuffer to the scene in the QGraphicsScene in my QGraphicsItem::paint() function?

        Industrial process automation software: https://simulton.com
        Embedded Graphics & GUI library: https://ugfx.io

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #6

          Oh, that sounds more advanced that I was thinking :)

          I was thinking pr Designer Item/widget.

          So we have a custom QGraphicsItem that will paint a image.

          This image is painted by your algorithms
          and the QGraphicsItem just show it in scene.

          Oh.
          "Maybe it would be possible that I maintain one framebuffer per QGraphicsItem "
          yes. That was my idea. Maybe its stupid but would be easy to test.

          Joel BodenmannJ 1 Reply Last reply
          0
          • mrjjM mrjj

            Oh, that sounds more advanced that I was thinking :)

            I was thinking pr Designer Item/widget.

            So we have a custom QGraphicsItem that will paint a image.

            This image is painted by your algorithms
            and the QGraphicsItem just show it in scene.

            Oh.
            "Maybe it would be possible that I maintain one framebuffer per QGraphicsItem "
            yes. That was my idea. Maybe its stupid but would be easy to test.

            Joel BodenmannJ Offline
            Joel BodenmannJ Offline
            Joel Bodenmann
            wrote on last edited by
            #7

            For me both is possible: I can either have a global framebuffer that contains the entire scene or I can have one buffer per QGraphicsItem. Our existing software design allows using either without modifying our renderers. So whatever is easier in terms of Qt will work.

            I would prefer to maintain one custom buffer per QGraphicsItem and then just dump that on the scene using a QPixmap or a QImage.

            Industrial process automation software: https://simulton.com
            Embedded Graphics & GUI library: https://ugfx.io

            1 Reply Last reply
            0
            • mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by mrjj
              #8

              Well I sort of like the one buffer pr item better - also -
              as it seems more flexible than render whole scene. :)

              Joel BodenmannJ 1 Reply Last reply
              0
              • mrjjM mrjj

                Well I sort of like the one buffer pr item better - also -
                as it seems more flexible than render whole scene. :)

                Joel BodenmannJ Offline
                Joel BodenmannJ Offline
                Joel Bodenmann
                wrote on last edited by
                #9

                Is it correct that I should prefer using a QPixmap instead of a QImage for this purpose?

                Industrial process automation software: https://simulton.com
                Embedded Graphics & GUI library: https://ugfx.io

                mrjjM 1 Reply Last reply
                0
                • Joel BodenmannJ Joel Bodenmann

                  Is it correct that I should prefer using a QPixmap instead of a QImage for this purpose?

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by
                  #10

                  @Joel-Bodenmann

                  Well depends on what you need pixels wise.
                  QImage has better support for
                  image manipulation and QPixmap is optimized for fast drawing.

                  So you might need QImage to generate the buffer but later convert to pixmap for
                  repeated drawing.

                  Its a wide question as seen here
                  http://stackoverflow.com/questions/10307860/what-is-the-difference-between-qimage-and-qpixmap

                  :)

                  1 Reply Last reply
                  1
                  • Joel BodenmannJ Offline
                    Joel BodenmannJ Offline
                    Joel Bodenmann
                    wrote on last edited by
                    #11

                    Thank you very much for your help, I appreciate it a lot!
                    I'll try to get this done in the next couple of days.

                    Industrial process automation software: https://simulton.com
                    Embedded Graphics & GUI library: https://ugfx.io

                    mrjjM 1 Reply Last reply
                    0
                    • Joel BodenmannJ Joel Bodenmann

                      Thank you very much for your help, I appreciate it a lot!
                      I'll try to get this done in the next couple of days.

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      @Joel-Bodenmann
                      You are very welcome.
                      I hope it will work as fine as I imagine :)

                      Good luck and happy coding !

                      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