PDA

View Full Version : Interpolate graphj



Morea
13th January 2007, 11:27
Hello.
In an application I get a plot but no data. I wish to pick a few points along the graph with a Qt application by letting the user click in the other application and then reading the coordinates inside of the qt app.
So how to do this? A single huge maximized transparent mainwindow?

jpn
13th January 2007, 12:08
You can grab the mouse to be able to receive mouse events outside the widget. That particular widget receives all the mouse events until the mouse grab is released.

See QWidget::grabMouse() and QWidget::releaseMouse() for more details. There's a reasonable warning about grabbing bugs in the QWidget::grabMouse() docs. Mouse-grabbing is very error prone and the bugs are nasty, so pay special attention while writing mouse grabbing/releasing code. :)

Morea
13th January 2007, 18:53
Thanks.
One quesion though, There is no way to get the "transparent window" solution to work?

jpn
13th January 2007, 19:34
One quesion though, There is no way to get the "transparent window" solution to work?
Sure, but all platforms supported by Qt don't support transparency by default. See the notes of QWidget::setWindowOpacity():


This feature is available on Mac OS X, X11 platforms that support the Composite extension, and Windows 2000 and later.

Note that under X11 you need to have a composite manager running, and the X11 specific _NET_WM_WINDOW_OPACITY atom needs to be supported by the window manager you are using.

If the aforementioned conditions are not met, you get no transparent windows either.

Morea
14th January 2007, 09:41
Since intend to be working outside of my own application, is there a way of drawstuff outside of my own application? If I click on two points outside of my app and wish to make these the corners of a rectangle for example?

jpn
14th January 2007, 11:00
Painting outside a window (for example on QDesktopWidget) is not reliable as it's not supported on all platforms. I don't even know on which platforms it does work. But there is a technique called masking (http://doc.trolltech.com/4.2/qwidget.html#setMask) which makes it possible to make only certain parts of the window visible. Also, the good thing is that it works reliably on all supported platforms.

So, what I suggest is actually creating window to draw the stuff like the rectangle. Then just mask out everything but the rectangle, possibly make it "always on top" and hide the taskbar entry for it. :)