PDA

View Full Version : Grey out background windows while editing a dialog.



Yevgen
3rd March 2014, 13:45
Hello,

in order to get a modal dialog focused, I want to make a semi-transparent backgound, which greys out the main window of the qt application while editing the dialog. The problem is similar to http://www.qtcentre.org/threads/6171-graying-out-window .
However, the proposed solution is not good for me, because I dont want to have the background widows disabled (it is a lot of work to disable them when the dialog pops up and reactivate, when it gets closed and it lookes worser then the transparent grey full-screen background).

I have tried to create a full-screen widget in my QDialog::open method and draw a Pixmap on that, but the widget was drawn behind the main window.

Does anybody have an idea how to do that.

Thanks for any help in advance,

Yevgen

anda_skoa
3rd March 2014, 14:54
The new widget needs to be a child of the window it should over, just not be in any of its layouts.

What kind of system are you on? Most modern systems can do that all by themselves, without any application needing to do anything about it.

Cheers,
_

Yevgen
3rd March 2014, 15:20
hello anda_skoa, thank you for your answer.

The app should run on windows and linux.


The new widget needs to be a child of the window it should over, just not be in any of its layouts.
I want to grey out the main window. Following the proposed approach, my dialog needs a pointer to his "backgrounder-widget", which should be a child of a main window. Thus, I need to propagate this pointer from the main window to the dialog widget and call show()/hide() on the pointer when the dialog opens/closes. There are a lot of intermideate widgets between the main window and the dialog, each of them has to take over this pointer to one of its children. Is there are some shortcut how to make it easier?

anda_skoa
3rd March 2014, 21:37
One possible way could be an event filter.
E.g. implement the eventFilter method in your main window and install it as an even filter on the QApplication object.

In the filter function check for show and hide events. if the object passed to the filter function inherits from QDialog, show/hide the "cover" widget accordingly.

I guess you want to support Windows XP, which doesn't have that kind of effect, right?

Cheers,
_

Yevgen
4th March 2014, 07:28
Hmm, that is a nice idea.

The XP is one of the target plattforms, however, it would be not so bad, if it does not work on xp. :)

Thanx

anda_skoa
4th March 2014, 09:43
I was mentioning XP because I think this is the only desktop platform which does not use compositing effects.
All of the more modern platforms have these kinds of effects built-in, so adding something manually might actually interfere.

Cheers,
_