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. FingerPaint App - QTouchEvent example
QtWS25 Last Chance

FingerPaint App - QTouchEvent example

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 2 Posters 7.3k 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.
  • T Offline
    T Offline
    tskd
    wrote on last edited by
    #1

    I am trying to modify the fingerPaint app that comes with the MultiTouch example of the SDK, so that it does not display the whole history of events and avoid making it a solid line.
    Instead I am using Qt::NoBrush with drawEllipse so that only finger points are painted. But again, I do not want the history displayed. If I am using 5 fingers, I just want 5 rings moving around in the window.
    To try this, I have been using the QPainter::eraseRect method with the rect corresponding to the QPoint touchPoint.lastPos(), before painting the current touchPoint. I am doing this in the TouchPointMoved case, so the previous rect is erased.

    This is leaving a lot of residue and not very accurate. There's got to be a better way for this, right?
    I am 1 day old with QT, so please bear if this question does not make sense.

    Thanks

    1 Reply Last reply
    0
    • ? This user is from outside of this forum
      ? This user is from outside of this forum
      Guest
      wrote on last edited by
      #2

      if u see the code of the fingerpaint app, the painter draws directly on the image on every touch event. the image is permanently modified here ... so u have to work around keeping this in mind

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

        Some ideas you could try:

        • If using eraseRect(), make sure when update() is called in the foreach loop, it includes the areas where you've called erase as well as the new areas you've painted.
        • If using eraseRect(), make the area you erase slightly larger (like in update(), where adjusted() is called).
        • Alternatively, don't use eraseRect(), and just clear the whole image before painting the touch points, e.g. before the foreach loop, add @image.fill(qRgb(255, 255, 255));@

        Michael

        1 Reply Last reply
        0
        • ? This user is from outside of this forum
          ? This user is from outside of this forum
          Guest
          wrote on last edited by
          #4

          not sure eraseRect can help here, you will have to repaint that rect from the original image, there may be accuracy issue as tskd has already tried

          clearing whole image and repainting will work, but not sure if there will be flicker.

          another approach that can be tried is to use a qgraphicsview, and graphics items are created at touch points and these items are moved around instead of painting on original image

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

            Thanks Michael and Chetan.

            True, I had tried clearing the screen earlier before each event and there was a lot of flicker and lag.

            The qgraphicsview approach seemed to work best. A colleague who is really good at this demonstrated it today incidentally and it seemed to work great. I am yet to try it on more than one touch point.

            Thanks for your informed answers!

            1 Reply Last reply
            0
            • ? This user is from outside of this forum
              ? This user is from outside of this forum
              Guest
              wrote on last edited by
              #6

              glad it worked :)

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

                [quote author="chetankjain" date="1283405899"]not sure eraseRect can help here, you will have to repaint that rect from the original image, there may be accuracy issue as tskd has already tried[/quote]

                Right, good point. I was assuming the image was just a plain white fill. Thanks for the clarification.

                Michael

                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