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. Mixing QML GUI and GraphicsView painting

Mixing QML GUI and GraphicsView painting

Scheduled Pinned Locked Moved QML and Qt Quick
8 Posts 2 Posters 3.7k Views
  • 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.
  • M Offline
    M Offline
    micha4fun
    wrote on last edited by
    #1

    Hi,

    I want to write something like a game for children. The background shall be something like a cheat of paper.
    The users can paint on it like in Scribble. Additionally they can insert elements like shapes and more complex elements modeled in Qml. Last but not least it wouldl be great to add Flash content as well.

    I guess I have to use a QGraphicsView / ~scene and insert the Qml elements as GraphicsItem, so that it is possible to zoom in and out, change the z-order of the elements, so that the paintings can lay above as well as under the Qml elements. Am not sure if Flash can be handled in the same way.

    Is the direction right or am I missing something? Do you have maybe some additional hints or links about this topic? I just used Google too, but without the right questions it is difficult to get the right answers :)

    Thanks in advance!
    Micha

    1 Reply Last reply
    0
    • Z Offline
      Z Offline
      ZapB
      wrote on last edited by
      #2

      You could mix QML into your graphics scene or equally valid you could you QGraphicsView on its own.

      Nokia Certified Qt Specialist
      Interested in hearing about Qt related work

      1 Reply Last reply
      0
      • M Offline
        M Offline
        micha4fun
        wrote on last edited by
        #3

        Thanks for the short reply. But there is still one question open (ok, I didn't mention it in my first post):
        If I do it the opposite way ... exporting GraphicsItems to QML ... can I export there ex. lines too (e.g. from PathStroke example)?

        1 Reply Last reply
        0
        • Z Offline
          Z Offline
          ZapB
          wrote on last edited by
          #4

          To be honest I am not sure how you would go about having an item you can paint on within QML - well I have a very vague notion but it is so vague it is not worth mentioning.

          I would go for QGraphicsView/Scene for this application. Just use QGraphicsPixmapItem (or svg based item) for your pre-defined shapes etc.

          Nokia Certified Qt Specialist
          Interested in hearing about Qt related work

          1 Reply Last reply
          0
          • M Offline
            M Offline
            micha4fun
            wrote on last edited by
            #5

            Hmmm ... thanks for the answer. Would the new QML scene graph resolve this problem?

            1 Reply Last reply
            0
            • Z Offline
              Z Offline
              ZapB
              wrote on last edited by
              #6

              I think not specifically. I think it is doable with a custom QML item but not trivial. You would need a custom item that would need to track mouse movements following a mouse down event. During the drag your custom item would need to adjust its bounding rect as well as keep painting itself.

              Since you will be doing all this in the C++ side of things anyway I just suggested doing the whole scene management in QGraphicsView.

              Nokia Certified Qt Specialist
              Interested in hearing about Qt related work

              1 Reply Last reply
              0
              • M Offline
                M Offline
                micha4fun
                wrote on last edited by
                #7

                Thank you for the new replay :)
                The approach you mentioned doesn't sound bad, even it would be a little bit of work :)
                Do you know probably a project, link or something like this for a follow up study?

                1 Reply Last reply
                0
                • Z Offline
                  Z Offline
                  ZapB
                  wrote on last edited by
                  #8

                  I would start by trying to port the "Scribble":http://doc.qt.nokia.com/latest/widgets-scribble-scribblearea-h.html example that ships with Qt to QGraphicsView and take it from there.

                  Nokia Certified Qt Specialist
                  Interested in hearing about Qt related work

                  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