Hello,
I want to create a selection tool for scribble program.

My scribble area is based on a QPainter in a QQuickPaintedItem.
Now I want to program a feature, that can select a region of the image.

I like to mark the selected area with a dashed outer line like this:
selection-adding.gif
beside a rectangle tool, I want to create a circle tool, too.


My problem is to get a good performance in my implementation. If the user click or dragging the cursor on the area, I want to give realtime feedback (select the area on the fly) but the framerate is very ugly.
My circle selection tool looks like:

Qt Code:
  1. void ImageView::selectPoint(const QPointF & point)
  2. {
  3.  
  4. int radius = 20;
  5. QPainter painter(&image);
  6. QBrush brush;
  7. brush.setStyle(Qt::SolidPattern); // Fix your problem !
  8. brush.setColor(QColor(60,20,20));;
  9. selection.addEllipse(point, radius, radius);
  10. painter.fillPath(selection.simplified(), brush);
  11. QRect currRect = QRect(point.x()- radius, point.y() - radius,radius+radius, radius+radius);
  12.  
  13.  
  14.  
  15. update(currRect);
  16.  
  17.  
  18. }
To copy to clipboard, switch view to plain text mode 

I'm also have the problem to draw only the outer line of the selection because I don't clear the image. Is there a option to work with layers (like in a QGraphicsView)?


Best Regards