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. Dynamic preview while drawing

Dynamic preview while drawing

Scheduled Pinned Locked Moved General and Desktop
qgraphicsitemqgraphicsscenepyqt4qgraphicsview
1 Posts 1 Posters 1.0k 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.
  • B Offline
    B Offline
    Boman
    wrote on 30 Jun 2015, 19:15 last edited by Boman
    #1

    Hi,

    I am making an app that enables drawing shapes using mouse. I use QGraphicsScene and I add Items to it and then the modified scene is being displayed by QGraphicsView. Everything works fine but I want to extend the program and add dynamic preview of an item the is being currently drawn. Id like to achive the same effect as it is in MS Paint or any graphic editor. I found many tutorials how to do it with paintEvent and QPainter but this approach isn`t suitable in my case. How can I do this with QGraphicsScene? I have overwritten MousePressEvent so it catches position of the cursor - 1st point of my item (e.g. line). MouseMoveEvent does the same but with the last point. That 2 points go to the function that draws line based on them. With this approach I get many lines, because everytime the cursor position is changed another line is being drawn. I tried to remove them so only the last one (the newest) is visible but I cannot do it right. I can delete them all or I cannot delete them at all. I want to have preview of a line while I press and hold LMB and move mouse cursor. After releasing the button I need the line to be added permanently to the scene. Can you please give me so ideas how can I solve this problem? I use pyqt 4 and python 3.4 .

    1 Reply Last reply
    0

    1/1

    30 Jun 2015, 19:15

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved