c++ - Interactively editing an existing rectangle on a QPixmap? -


i'm trying creat dicom gui toolkit user selects dicom images , image of first dicom image selected ones shown. user clicks on image , image pops out bigger image window. in shown bigger image, image consist of red colored rectangle contains necessary regions of dicom image while unnecessary region outside rectangle. user should have option change rectangle mouse.

until now, have been able show big dicom image rectangle in using qlabel following code snippets.

void mainwindow::showbigimage() {     qpixmap bigimage;     bigimage.load(imagename.c_str());     qpainter painter(&bigimage);     painter.setpen(qt::red);     qrectf rect(xmin, ymin, xmax, ymax);     painter.drawrect(rect);     qsize bigsize = ui->bigimagelabel->size();     ui->bigimagelabel->setpixmap(bigimage.scaled(bigsize, qt::ignoreaspectratio, qt::fasttransformation));     ui->bigimagelabel->show(); } 

and big image on app looks following:

enter image description here

can please suggest me how should make rectangle editable user user can set existing red rectangle per or wish?

i tried similar thing using qgraphicsview , qgraphicsscene following code:

void mainwindow::showbigimage() {     qgraphicsscene* scene = new qgraphicsscene;     scene->addpixmap(bigimage);     ui->bigimageview->setscene(scene);     ui->bigimageview->show(); } 

and code gives me following look:

enter image description here

as can see, not fit image boundaries of qgraphicsview, suggest me how it? suggest me how add red rectangle(that showed in example using qlabel) on qgraphicsview without adding rectangle on qpixmap?

in order red selection rectangle, qt provides class qrubberband. docs state:

the qrubberband class provides rectangle or line can indicate selection or boundary.

by subclassing image object , implementing mouse handling functions, create rubber band on mousepressevent, update position on mousemoveevent , grab final rect on mousereleaseevent, qrubberband simplify problem.

if want qrubberband show time, create when display enlarged image , don't hide on releasing mouse button.

as displaying image in qgraphicsview, code displayed doesn't set geometry of qgraphicsscene , qgraphicsview, you're seeing border. if don't want that, should set them accordingly. note qgraphicsview has function fitinview, use, after having retrieved area qrubberband, in order zoom selected area.


Comments

Popular posts from this blog

design - Custom Styling Qt Quick Controls -

Unable to remove the www from url on https using .htaccess -