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:
void ImageView
::selectPoint(const QPointF & point
) {
int radius = 20;
brush.setStyle(Qt::SolidPattern); // Fix your problem !
brush.
setColor(QColor(60,
20,
20));;
selection.addEllipse(point, radius, radius);
painter.fillPath(selection.simplified(), brush);
QRect currRect
= QRect(point.
x()- radius, point.
y() - radius,radius
+radius, radius
+radius
);
update(currRect);
}
void ImageView::selectPoint(const QPointF & point)
{
int radius = 20;
QPainter painter(&image);
QBrush brush;
brush.setStyle(Qt::SolidPattern); // Fix your problem !
brush.setColor(QColor(60,20,20));;
selection.addEllipse(point, radius, radius);
painter.fillPath(selection.simplified(), brush);
QRect currRect = QRect(point.x()- radius, point.y() - radius,radius+radius, radius+radius);
update(currRect);
}
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
Bookmarks