PDA

View Full Version : Selection area on image



sdwdd
1st March 2009, 02:59
Hi, All.

I'm a total newbie here. Came from .NET development and having an urgent task on developing a Qt-application.

Here's the task:
I need to place an image on the form and provide user with ability to place a selection rectangle on the image, move it, resize etc. You know, like Adobe Photoshop's "Selection tool".
Moving/resizing the selection rectangle should be keyboard-controlled, so I need something with strong API.

Looks pretty easy, but what about Qt?
Is there anything premade for my purposes?

Any helpful links appreciated.

Thanks.

boudie
4th March 2009, 22:32
In a nutshell:

Subclass QLabel and put your image onto it.


QPixmap pixmap(fotoPath, "", 0);
pictureWindow->setPixmap(pixmap);


Implement its paintEvent to draw a "rubber band".
Have a look at QPainter to see how it's done.

Implement its keyPressEvent to update() the widget when keypresses arrive.

Life's good, with Qt :)

sdwdd
5th March 2009, 11:09
I've implemented that in another way:
created a QGraphicsScene and loaded 2 QGraphicsItem there:
one for the image
second for the selection rect with QGraphicsItem::ItemIsMovable

that actually is more satysfying my needs

thanks for the reply