Screenshot from selected area (QRubberBand) on Qt

I am trying to create a Qt application to take a screenshot of a selected area on the screen. I am currently using QRubberBand to select an area of ​​the screen. It works like that.

  • When the Capture button clicked on a transparent overlay widget, a pop-up window will appear (full-screen, but without frames).
  • I use QRubberBand to select the area of ​​the transparent widget.

Now I need to take a screenshot of the screen I selected.

I think I need to pass the sizes that I get from the QRubberBand selection:

screen->grabWindow( WId window, int x = 0, int y = 0, int width = -1, int height = -1 );

So, how do I get the information I need from QRubberBand? I'm stuck here, so someone please help me!

+4
source share
1 answer

OnMouseRelease QRubberBand geometry(). , QRect::getRect, x y .

const QRect & selectRect = mRubberBand->geometry();
int x, y, width, height;
selectRect.getRect(&x, &y, &width, &height);
+2

Source: https://habr.com/ru/post/1546789/


All Articles