tags:

views:

98

answers:

2

Hello,

How can I draw a selection rectangle on my screen with Qt in X11? I want to be able to drag a rectangle on my screen (outside of the application) and then save the whole rectangle.

Thanks in advance.

+3  A: 

This link has answer to your question

http://doc.trolltech.com/qq/qq20-qss.html

Ravi shankar
Huh? That's not even related to what I want...
mkroman
Indeed, it is not. I don't quite understand how this answer got 5 upvotes.
Arnold Spence
+2  A: 

Part of the solution will involve using the grabWindow() function of QPixmap like so:

QPixmap::grabWindow(QApplication::desktop()->winId());

Qt has an example program for this here.

There rest of the solution, drawing the area to grab, can probably be achieved by either using a full screen transparent window to render a mouse drawn rectangle and then taking the section it outlines from the grabbed desktop image or using a full screen window with the entire grabbed screen painted on it.

Arnold Spence
Hmm, yeah, I know. This was my initial approach. Since I'm writing a screenshot utility, do you think the time it will take for it to initialize itself and take a full-sized screenshot is gonna be noticeable?
mkroman
I would imagine it to be as responsive as any other screenshot utility. Building and testing the example program would be a quick experiment.
Arnold Spence
Myeah, okay, I'm just gonna go with your answer. Thanks.
mkroman