Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I darken the main window when the child dialog was showed
Forum Updated to NodeBB v4.3 + New Features

How can I darken the main window when the child dialog was showed

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 5 Posters 637 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MihanM Offline
    MihanM Offline
    Mihan
    wrote on last edited by Mihan
    #1

    Hi
    I want to make an effect like when Qt creator open the option dialog, the main window will be darkened.
    I just think of a way that show another window with rgba:(0,0,0,0.6) in the main window, but it's so silly I think lol.
    Could you give me some suggestions?

    Regards
    Mihan

    jsulmJ 1 Reply Last reply
    0
    • MihanM Mihan

      Hi
      I want to make an effect like when Qt creator open the option dialog, the main window will be darkened.
      I just think of a way that show another window with rgba:(0,0,0,0.6) in the main window, but it's so silly I think lol.
      Could you give me some suggestions?

      Regards
      Mihan

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Mihan said in How can I darken the main window when the child dialog was showed:

      I want to make an effect like when Qt creator open the option dialog, the main window will be darkened

      On which platform is it like this? It's not like this on Linux/Windows.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @jsulm said in How can I darken the main window when the child dialog was showed:

        It's not like this on Linux/Windows.

        On Linux it's a window manager setting. E.g. openbox does this by default (and is imo very stressful for the eyes)

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        jsulmJ 1 Reply Last reply
        2
        • Christian EhrlicherC Christian Ehrlicher

          @jsulm said in How can I darken the main window when the child dialog was showed:

          It's not like this on Linux/Windows.

          On Linux it's a window manager setting. E.g. openbox does this by default (and is imo very stressful for the eyes)

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @Christian-Ehrlicher I use XFCE on Linux - it does not behave like this. But you're right - Linux isn't Linux :-)

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • MihanM Offline
            MihanM Offline
            Mihan
            wrote on last edited by
            #5

            @Christian-Ehrlicher @jsulm
            Sorry, I'm late.
            I'm using Ubuntu with Qt 5.12.0(creator 4.8.0).
            2020-03-12 15-19-13 的屏幕截图.png
            Tools-> Options..., then will show the effect I want.

            JonBJ 1 Reply Last reply
            0
            • MihanM Mihan

              @Christian-Ehrlicher @jsulm
              Sorry, I'm late.
              I'm using Ubuntu with Qt 5.12.0(creator 4.8.0).
              2020-03-12 15-19-13 的屏幕截图.png
              Tools-> Options..., then will show the effect I want.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #6

              @Mihan
              Like me, you are using the GNOME window manager.

              I do not believe this has anything to do with your code or Qt. As others have said it should be purely window manager behaviour.

              It should already be doing what you say you want. It does for me. All you have to do is do e.g.. a QDialog::exec() with your main window as the parent, and you should see it is "darkened" while your dialog is up-front.

              You should also be seeing this behaviour from other programs.

              I bet you are using nullptr as the parent of your dialog? In that case it is "application" instead of "window" modal, and you won't see the darkening of the main window. Is that it?? :)

              1 Reply Last reply
              2
              • gde23G Offline
                gde23G Offline
                gde23
                wrote on last edited by
                #7

                It also may depend if you use exec() or show() for the dialog, as well as what WindowFlags are set (blocking or non blocking dialog)

                1 Reply Last reply
                3

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved