PDA

View Full Version : Geometry relative to desktop



thrall
25th October 2010, 17:26
Hi all,

I search a way to get the geometry of a widget relative to the desktop instead relative to the parent widget.
Does anyone know how to do that?

What I want to achieve is to grab the desktop and show my application maximized and put the desktop image in a graphics scene. That already works, but only if I remove window decoration. Since I want to keep it i have to move the grabbed image about the decorations size.

Regards

wysota
25th October 2010, 18:42
QWidget::mapToGlobal()

thrall
25th October 2010, 19:57
Thanks, that partly worked, but only of I use showMaximized(). If I use showFullScreen() instead (without removing windows decoration), mapToGlobal(QPoint(0,0)) retuns 0,0. Why?

I now tried to first do showMaximized() followed by mapToGlobal() and then showFullScreen(), but this gives me some unwanted flicker.

wysota
25th October 2010, 20:11
mapToGlobal(QPoint(0,0)) retuns 0,0. Why?
Because if you show a widget full screen then its 0,0 point corresponds to screen's 0,0 point.

genjix
25th October 2010, 20:27
I read your post several times and it's not clear what you're trying to do. Maybe this will help? (http://doc.qt.nokia.com/4.7/desktop-screenshot.html)

thrall
25th October 2010, 20:36
Because if you show a widget full screen then its 0,0 point corresponds to screen's 0,0 point.

Yes, that would be true, but the widget is not really full screen, there is still the window decoration around it, especially the title bar above it.

Visually I have no difference between maximazied window and full screen window, thus I expected both to return same result, because the main widget occupies the same screen area in both cases.

wysota
25th October 2010, 20:38
Yes, that would be true, but the widget is not really full screen, there is still the window decoration around it, especially the title bar above it.
Then it's maximized rather than full screen. You are probably calling both methods.

thrall
25th October 2010, 21:22
Then it's maximized rather than full screen. You are probably calling both methods.

Yes, you are right. It was a bit hidden in my code, but there was another showMaximized(). Thank you for your help :D.

So I guess I can not have decoration for full screen window. Right?

Added after 22 minutes:


I read your post several times and it's not clear what you're trying to do. Maybe this will help? (http://doc.qt.nokia.com/4.7/desktop-screenshot.html)

Thanks.

What I already do is grabbing the desktop and showing it in my application at same position and size. What I was trying to achieve is having a full screen application with window decoration. Now I plan to add my own control at bottom or top of the screen. That could even look nicer than ordinary window decoration.

Background: the task is rather simple. It's a little toy application for my son, which is 8 months old. He loves to play with our keyboard and mice, while we are working on computer. If that happens I can start my application which then lock all keyboard input (waiting for simple password to unlock or klick on unlock button). While the input is locked keystrokes are turned in some action (showing different pictures and sound, each et least for 1/2 second). That is already working and lot of fun for my son :).
(I know, there are already plenty of application doing the very same. But 1. I can not extend them and they did not have everything I wanted the way I wanted. And 2. its fun to program).

d_stranz
26th October 2010, 02:43
Very nice application idea! I hope your son has some good fun using it. Maybe as he gets older you can make it more challenging - instead of just showing pictures and sounds for any keystroke, maybe he has to type some correct Qt code first. Then he could help you with your programming. :D