Results 1 to 6 of 6

Thread: Grey out background windows while editing a dialog.

  1. #1
    Join Date
    Mar 2014
    Posts
    5
    Thanks
    2

    Default Grey out background windows while editing a dialog.

    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:pen 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

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Grey out background windows while editing a dialog.

    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,
    _

  3. #3
    Join Date
    Mar 2014
    Posts
    5
    Thanks
    2

    Default Re: Grey out background windows while editing a dialog.

    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?

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Grey out background windows while editing a dialog.

    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,
    _

  5. #5
    Join Date
    Mar 2014
    Posts
    5
    Thanks
    2

    Default Re: Grey out background windows while editing a dialog.

    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

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Grey out background windows while editing a dialog.

    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,
    _

  7. The following user says thank you to anda_skoa for this useful post:

    Yevgen (5th March 2014)

Similar Threads

  1. Double Buffering on QGLWidget - Background always grey
    By StarShaper in forum Qt Programming
    Replies: 0
    Last Post: 31st March 2012, 17:35
  2. Dialog remains in background.
    By vjsharma_30 in forum Qt Programming
    Replies: 4
    Last Post: 15th March 2010, 23:12
  3. Dialog Background Color using Hand Code
    By augusbas in forum Qt Programming
    Replies: 2
    Last Post: 5th June 2009, 09:30
  4. code become grey
    By weixj2003ld in forum Qt Programming
    Replies: 3
    Last Post: 16th April 2009, 15:44
  5. How to dim / blur the background dialog?
    By german@it-missions.com in forum Qt Programming
    Replies: 2
    Last Post: 18th February 2009, 08:40

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.