Re: Creating an Icon-Editor
This paintEvent() implementation is very inefficient.
1 Attachment(s)
Re: Creating an Icon-Editor
Hi,
I know, that paintEvent() repainted the whole area, even if just one pixel changed.
Now, paintEvent() looks like this:
Code:
{
QRect updateRect
= event
->rect
();
updateRect
= QRect(updateRect.
topLeft() / zoom, updateRect.
size() / zoom
);
for(int i = updateRect.left(); i <= updateRect.right(); ++i) {
if(!image.rect().contains(i, 0)) break;
for(int j = updateRect.top(); j <= updateRect.bottom(); ++j) {
if(!image.rect().contains(0, j)) break;
QRect rect
= pixelRect
(i, j
);
if(!event->region().intersect(rect).isEmpty()) {
if(color.alpha() < 255)
painter.fillRect(rect, color);
painter.fillRect(rect, color);
}
}
}
}
So, only the part that changed is repainted. But it's still not possible to paint a continuous line.
Is there a better way to implement paintEvent()?
Re: Creating an Icon-Editor
Since mouse events are not coming on every one pixel change when moving cursor fast, then you have draw line (not only pixel) from the last mouse position (which you have to save on mouse move event I think) to current position.
Re: Creating an Icon-Editor
That sounds simple. I will try it, thank you. :)
Re: Creating an Icon-Editor
I have this icon editor in my project..........i need to know how can i display the text on this icon editor....
For Ex: I have a line edit in which am goingto eb=nter a text which it should display on the icon editor.......... how can i do this???pls help