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. Eraser tool in QGraphicView
Forum Updated to NodeBB v4.3 + New Features

Eraser tool in QGraphicView

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 615 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.
  • H Offline
    H Offline
    huylv
    wrote on last edited by
    #1

    Hello, I have created a drawing tool like MS Paint follow this tutorial: https://evileg.com/en/post/84/
    Now i want to create eraser tool help me to erase the drawn line. Please help me, maybe a working example is good for me.b19d9632-14db-4985-ba41-e48164ccb58b-image.png

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to the forums

      You can use
      QGraphicsItem *item = itemAt(event->scenePos())
      in mousePress to get the item under mouse and
      remove the lines with removeItem()

      You need a button to toggle between drawing and erasing.

      However, if you plan on making a small Raster paint app like MS paint then I'm not sure you
      are on the right path using QGraphicView.
      At least what was drawn here is a vector. tons of line segments.
      so it's not an image as it's in MS Paint. Just so you are aware that some operations
      will be harder than using a pure QPainter approach.

      I think you want more like
      https://github.com/yakzi/paint-qt

      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