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. How to paint using a ball shape and get painted coordinates in qml?

How to paint using a ball shape and get painted coordinates in qml?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
10 Posts 2 Posters 636 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.
  • YunusY Offline
    YunusY Offline
    Yunus
    wrote on last edited by
    #1

    Hi all,

    I want to create a small rounded shape(ball shape) which should be movable. After that I will move it on the screen to be able to paint the areas which it passed. At the end of the process, I need to get the coordinates of painted areas.

    How can I achieve this? Is there an example which is helpful for my problem? I am new on Qt so I prefer examples to adviced methods.

    ODБOïO 1 Reply Last reply
    0
    • YunusY Yunus

      Hi all,

      I want to create a small rounded shape(ball shape) which should be movable. After that I will move it on the screen to be able to paint the areas which it passed. At the end of the process, I need to get the coordinates of painted areas.

      How can I achieve this? Is there an example which is helpful for my problem? I am new on Qt so I prefer examples to adviced methods.

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @Yunus hi,
      you can use qml Canvas

      1 Reply Last reply
      1
      • YunusY Offline
        YunusY Offline
        Yunus
        wrote on last edited by
        #3

        @LeLev Yes Canvas is a possible solution but I dont know how to use it in my case :)

        ODБOïO 1 Reply Last reply
        0
        • YunusY Yunus

          @LeLev Yes Canvas is a possible solution but I dont know how to use it in my case :)

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by ODБOï
          #4

          @Yunus http://qteveloper.blogspot.com/2013/08/qml-example-detect-mouse-and-draw-on.html
          see also
          https://doc.qt.io/qt-5/qtwidgets-widgets-scribble-example.html but it is widget

          1 Reply Last reply
          1
          • YunusY Offline
            YunusY Offline
            Yunus
            wrote on last edited by
            #5

            @LeLev Thanks for ur reply. This problem can solve my problem's 1st step but I have still a few questions:

            1. When I moved clicked mouse quickly, canvas cant draw quickly and appears some gaps between lines. Is there a way to fix this issue?
            2. fillRect method is good which is explained here. But I couldnt find a method for circle. Is there a method to do this with circle. Maybe normal "lineTo" method is already circle, But I cant put dots using "lineTo".
            3. The most important one: How can I get the coordinates of painted at the end of process?
            1 Reply Last reply
            0
            • YunusY Offline
              YunusY Offline
              Yunus
              wrote on last edited by
              #6

              Actually, I fixed my 1st and 2nd problem too, using lineCap by making it "round". My last problem is getting coordinates of painted part.

              ODБOïO 1 Reply Last reply
              0
              • YunusY Yunus

                Actually, I fixed my 1st and 2nd problem too, using lineCap by making it "round". My last problem is getting coordinates of painted part.

                ODБOïO Offline
                ODБOïO Offline
                ODБOï
                wrote on last edited by
                #7

                @Yunus said in How to paint using a ball shape and get painted coordinates in qml?:

                My last problem is getting coordinates of painted part.

                have an array, then in the onPaint handler add xpos, ypos to that array

                1 Reply Last reply
                1
                • YunusY Offline
                  YunusY Offline
                  Yunus
                  wrote on last edited by
                  #8

                  @LeLev But doesnt it give only the middle pixels of a thick line. Does it also give all the pixels inside a thick line or only the middle pixel of line?

                  ODБOïO 1 Reply Last reply
                  0
                  • YunusY Yunus

                    @LeLev But doesnt it give only the middle pixels of a thick line. Does it also give all the pixels inside a thick line or only the middle pixel of line?

                    ODБOïO Offline
                    ODБOïO Offline
                    ODБOï
                    wrote on last edited by
                    #9

                    @Yunus yes it will give positions where mouse moved.

                    you can also iterate over all the pixels of the canvas

                    1 Reply Last reply
                    1
                    • YunusY Offline
                      YunusY Offline
                      Yunus
                      wrote on last edited by
                      #10

                      @LeLev actually I saved the painted image to a directory using "canvas's save method". And I decided to use that image on C++ side by calling it from directory. I dont know this is efficient or not but I think this can solve my problem

                      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