temporal shapes in drawing application
Hi.
I'm making a drawing app and i want to be able to draw lines, rectangles, ellipses ,...
I've think making like this:
1- Save the starting point
2- Draw temporal shape based on the type of cursor
3- Finish the draw and add it to the scene
But i don't know how to make the second step, drawing the temporal shape (rectangle, circle, line, ...) while the user has the button pressed until it's released.
Some ideas?
Re: temporal shapes in drawing application
You have to develop logic for them, there is no ready to eat pasta.;);)
Play with these 3 events and you will get what you want.
For rectangle you can use this logic.
Code:
{
origin = event->pos();
if (!rubberBand)
rubberBand->show();
}
{
rubberBand
->setGeometry
(QRect(origin, event
->pos
()).
normalized());
}
{
rubberBand->hide();
// determine selection, for example using QRect::intersects()
// and QRect::contains().
}
Re: temporal shapes in drawing application
Thank you but this is useful only for one line or one rectangle, but not for more complex shapes like polylines or ellipses.
I think that i'll create a widget like a rubberband but a little more complex, and i'll use it the same way as you with the rubberband.
Others ideas?
Quote:
Originally Posted by
yogeshgokul
You have to develop logic for them, there is no ready to eat pasta.;);)
Play with these 3 events and you will get what you want.
For rectangle you can use this logic.
Code:
{
origin = event->pos();
if (!rubberBand)
rubberBand->show();
}
{
rubberBand
->setGeometry
(QRect(origin, event
->pos
()).
normalized());
}
{
rubberBand->hide();
// determine selection, for example using QRect::intersects()
// and QRect::contains().
}
Re: temporal shapes in drawing application
Quote:
Originally Posted by
parnedo
Thank you but this is useful only for one line or one rectangle,
That I already mentioned, this is only for rectangle.
Quote:
Originally Posted by
parnedo
but not for more complex shapes like polylines or ellipses.
This is true.
Quote:
Originally Posted by
parnedo
Others ideas?
What ideas, now you just go ahead, develop logic for how to draw a eclipse and all. I think now you dont have any Qt code related question. :)