Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. QQuickPaintedItem is not advised?
Forum Updated to NodeBB v4.3 + New Features

QQuickPaintedItem is not advised?

Scheduled Pinned Locked Moved QML and Qt Quick
12 Posts 3 Posters 9.5k 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.
  • Q Offline
    Q Offline
    qttester5
    wrote on last edited by
    #1

    According to the "docs":http://qt-project.org/doc/qt-5.0/qtquick/qquickpainteditem.html:

    "QQuickPaintedItem is meant to make it easier to port old code that is using the QPainter API to the QML Scene Graph API and it should be used only for that purpose."

    If we want to do custom drawing in a QML Rectangle, for example, is it not suggested to begin new development using QQuickPaintedItem? What is the alternative? It seems to be the closest technique I have found to do quick hardware accelerated drawing into a portion of a QML scenegraph.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      The alternative is the base class and reimplementation of "this method":http://qt-project.org/doc/qt-5.0/qtquick/qquickitem.html#updatePaintNode.

      Or use QML Canvas element.

      (Z(:^

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tower120
        wrote on last edited by
        #3

        And what if we need to make some kind of Graphic Editor? Like Paint.

        We should use QPaint api anyway, right? Even if we reimplement "this":http://qt-project.org/doc/qt-5.0/qtquick/qquickitem.html#updatePaintNode

        P.S. Just dont say that you'll advice customGeometry example (plus GL_LINE_STRIP work not so good as triangles on some hardware). If QPainter with OpenGL do the same, why to complicate?

        P.P.S And if talk about a few thousand objects (lines, arcs, etc.) overhead for tessellation 3d objects may be more than just draw it in usual way . For example, in 40000 chips example. when enabling openGL mode (window maximized) on nv9600 performance drops almost in 2-3 times.

        1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          [quote author="tower120" date="1375198026"]
          P.S. Just dont say that you'll advice customGeometry example (plus GL_LINE_STRIP work not so good as triangles on some hardware). If QPainter with OpenGL do the same, why to complicate?[/quote]

          Don't worry, I've never looked at any of Qt examples, so there is no danger that I'll mention them :P

          As for the second PS: experiment with OpenVG then.

          And in general: I don't know. QPainter is not recommended in scenegraph because it introduces another major level of abstraction, possibly hurting performance. But it's not really my area. The only custom painting on scenegraph that I did was to paint my texture on an item subclass - easy and straightforward.

          (Z(:^

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tower120
            wrote on last edited by
            #5

            OpenVG - what are you talking about? :)
            I just want to draw some vector graphic. Not launch rocket in space.
            Why to draw a few lines I have to do God knows what?
            You say that QPainter is bad, but show nothing to replace it with.

            [quote author="sierdzio" date="1375248780"]
            The only custom painting on scenegraph that I did was to paint my texture on an item subclass – easy and straightforward.[/quote]

            And you saying me that this is not my case? ;) You draw your texture with QPainter, right?

            P.S. If you are not from QT team - there is no offensive to you :)

            1 Reply Last reply
            0
            • T Offline
              T Offline
              tower120
              wrote on last edited by
              #6

              By the way, I made a small test.

              1. I tried to draw lines a la http://doc-snapshot.qt-project.org/qt5-stable/qtquick/scenegraph-customgeometry.html . But tried to draw them 10000 times. To do this I have to repeat object 10000 times.

              2. And I tried modified https://qt-project.org/doc/qt-5.1/qtopengl/2dpainting.html , which, also, draw at least 10000 lines.

              And at least on my hardware QPainter draw at least 2-3 times faster.
              Frankly speaking on my nv9600m 1st method just jam.

              Look attachments here:
              https://bugreports.qt-project.org/browse/QTBUG-32741

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                No I am not developing Qt, at least not yet. I plan to do some bug fixing, as Qt Project lacks manpower to fix bugs fast enough.

                Since QPainter is faster in your test, go for it ;) As for drawing the texture: I simply had a ready-made PNG file that I needed to be drawn :) So it differs from your needs.

                I have referred to OpenVG ("link":http://www.khronos.org/openvg/) because AFAIK Qt supports it, but I have never tried doing anything in it.

                (Z(:^

                1 Reply Last reply
                0
                • T Offline
                  T Offline
                  tower120
                  wrote on last edited by
                  #8

                  Even to use OpenVG I have to use QPainter :)))
                  http://qt-project.org/doc/qt-4.8/openvg-star.html
                  http://qt-project.org/doc/qt-4.8/openvg-star-starwidget-cpp.html

                  P.S. And what for your texture drawing - you could load it through the qml image, and then (if you need to operate it from C++) - load that qml Component. And in this way - you diffidently get rid from QPainter from your code :)))))

                  1 Reply Last reply
                  0
                  • sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #9

                    I think you misunderstood: I'm not using QPainter for this: "link":https://github.com/sierdzio/closecombatfree/blob/master/src/qmlBase/ccfqmlbasemap.h.

                    True I could go with pure QML, and it used to be the case in the initial prototyping period, but now I've moved most of the heavy stuff to C++. It's great fun and I've learned a lot: plus I was able to optimise the whole project a lot.

                    (Z(:^

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      tower120
                      wrote on last edited by
                      #10

                      I mean you could ONCE load .qml with Image, and then just use it. Add it to your Item, by setParent. From C++. Look here:
                      http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-interactqmlfromcpp.html
                      (Look "Loading QML Objects from C++")

                      And about the topic thread, sierdzio, you were wrong, just like and documentation:
                      https://bugreports.qt-project.org/browse/QTBUG-32741
                      :))

                      1 Reply Last reply
                      0
                      • sierdzioS Offline
                        sierdzioS Offline
                        sierdzio
                        Moderators
                        wrote on last edited by
                        #11

                        [quote author="tower120" date="1375358722"]And about the topic thread, sierdzio, you were wrong, just like and documentation:
                        https://bugreports.qt-project.org/browse/QTBUG-32741
                        :))[/quote]

                        I'm happy to be corrected! Thank you for the link.

                        @loading QML from C++: I know about this and am using it, too :) In that specific use case I needed to have the whole thing in pure c++ (lots of interactions with other classes). Anyway, we are getting way off the topic :P

                        (Z(:^

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          tower120
                          wrote on last edited by
                          #12

                          [quote author="sierdzio" date="1375359070"]. Anyway, we are getting way off the topic :P[/quote]

                          You're right, I just want qml Items could be created from C++ :) That would make life much easier.

                          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