PDA

View Full Version : how to creating a selection mask out of an image? please help



Not Fast Enough
28th April 2010, 12:39
hi, I'm having problem doing this project, i scoured web for help specific to my problem with no luck, the issue is that i did every thing using the designer and i dont know how to create simple thing like load an image in a scroll area and track mouse clicks to create a points then connect those points to create a mask for that image like in the example.

4560

it seems like simple things to do for a professional programmer but not to me, i'm frustrated.

this is the sample of my code


QGraphicsScene *scene = new QGraphicsScene(this);
scene->addPixmap(QPixmap::fromImage(image));
ui->graphicsView->setScene(scene);


and the last screen shot is from the interface i did, how can i fill the x and y labels with updated mouse coordinates and when user clicks i can create a point then when he clicks again i can create other point and connect them with a line so finally i would end up with a black shape on a white background, that black shape would represent the part that needs to be removed from the original image at a later stage.

4559

here is the screen shot of the interface, i used a QGraphicsView then put a QGraphicsScene with the image in it and it automatically shows scroll bars but when i want to save the image to a file using grabwidget the only saved part is the viewable part.

4561

any help is appreciated.

axeljaeger
6th May 2010, 10:13
This cannot be done in designer in a graphical manner. You will have to write some code.

Not Fast Enough
12th May 2010, 13:08
thanks, my main problem was tracking mouse pos on a certian label or scene. i finally did it using QEventFilter.
this topic was helpful: http://www.qtcentre.org/threads/6272-mouse-tracking-on-image