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. Painting the mouse trace with QGraphicsItem
Qt 6.11 is out! See what's new in the release blog

Painting the mouse trace with QGraphicsItem

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.9k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hello,

    I have a QGraphicsView with a scene that displays an image. What I am trying to do now is when I click the mouse and move without un-clicking, I want to draw the mouse trace until the mouse button is released. So basically to draw with the mouse.

    Could someone please guide me to what I need to do for this?

    So far what I am trying to do is subclassing QGraphicsRectItem and from the mouse events of the QGV call my own functions in the GraphicsItem subclass passing as a parameter the QMouseEvent and handling things there.

    I know I have to implement the paint event to draw, but I'm a bit lost how to approach this. I was thinking maybe getting the points of the trace and drawing small line segments in between, would this be a good possible way?

    I appreciate any help. Thanks.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Did you take a look at the Finger Paint example?
      You only replace QTouchEvent with QMouseEvent.

      Regards,
      Jake

      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