PDA

View Full Version : how can i take an image from a specific part of my mainwindow and save it?



Alex22
24th December 2015, 18:53
hi,
is it possible to take a picture from a certain place of the MainWindow and save it? like printscreen but only a piece and certain place of my window must be in the picture.

d_stranz
25th December 2015, 00:00
QWidget::render()

Alex22
25th December 2015, 06:34
Thanks d_stranz, I could save the entry of myMainWindow by under code:


MainWindow *w;
w = new MainWindow;
QPixmap pixmap(w->size());
w->render(&pixmap);
pixmap.save("h.bmp");
w->show();


I need to take an image from into the red box that you can see in the uploaded image. That the positions are:
position 1: beginning of "GroupBox"
position 2: top right of "b1"
position 3: down left of "GroupBox"
position 4: x=down left of "GroupBox", y=top right of "b1"

thanks for any help about working with 4 above positions because the size of MainWindow can be changed by pulling the window.
11589

anda_skoa
25th December 2015, 12:02
If you only want the groupbox then call its render() method.

If you need things across container widgets, render the widget that contains all and use QPixmap::copy() to extract the part you are interested in.

Cheers,
_

Alex22
25th December 2015, 12:09
If you only want the groupbox then call its render() method.

If you need things across container widgets, render the widget that contains all and use QPixmap::copy() to extract the part you are interested in.

Cheers,
_

thanks. no i need the red box screen-shot that i draw in uploaded image and contains the GroupBox and 4 PushButttons(not just GroupBox). I told which positions are needed. please help me to do by those positions (4 positions that i told in my before post above).

anda_skoa
25th December 2015, 12:52
You could put the buttons and the groupbox into a container widget and then render this widget.
Or you just calculate the coordinates manually and use the already mentioned copy method.

Cheers,
_

Alex22
25th December 2015, 13:28
You could put the buttons and the groupbox into a container widget and then render this widget.
Or you just calculate the coordinates manually and use the already mentioned copy method.

Cheers,
_

thanks anda, but sorry i am newbie in Qt. please give me an example