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. Move dialogs behind main window when it is clicked
Forum Updated to NodeBB v4.3 + New Features

Move dialogs behind main window when it is clicked

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 2.2k Views
  • 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.
  • D delos

    Hi

    I have a main Window (QMainWindow) with charts inside and the possibility to open a dialog that can modify the contents (data) of the chart.
    It works fine with a QDialog. Though, when I change a value inside the dialog, I would like to see what happens in the main window. Of course I can move the dialog away with the mouse so I can see the whole main window or chart, respectively.
    Some users might not have the space on their desktop, though. Therefore, it would be nice to move the main window to the front when it is clicked.
    Up to now I tried to play with the "modal" flag of both windows and the "show()" method. None of them brings the dialog in the background when I chose the main window.
    Is there some flag that can be set to achieve that?
    I am using Qt creator and Windows 10.

    Best regards
    delos

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

    @delos
    I do not know whether/how easy you can put something on top of a modal dialog, because that is intended to be on top. Have you at least tried https://doc.qt.io/qt-5/qwidget.html#raise?

    EDIT LOL, crossed with @jsulm . It's not fair because he types in less words than I do ;-)

    jsulmJ 1 Reply Last reply
    1
    • JonBJ JonB

      @delos
      I do not know whether/how easy you can put something on top of a modal dialog, because that is intended to be on top. Have you at least tried https://doc.qt.io/qt-5/qwidget.html#raise?

      EDIT LOL, crossed with @jsulm . It's not fair because he types in less words than I do ;-)

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

      @JonB Germans say: "In der Kürze liegt die Würze" :-D
      English: "Brevity is the soul of wit"

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

      1 Reply Last reply
      1
      • D Offline
        D Offline
        delos
        wrote on last edited by
        #5

        Hi

        Usually Germans assemble long sentences ;-) So thanks for the quick and short answers.
        At what point should I call "raise()"? I want the main window to pop into the front when I click on it.

        Cheers
        delos

        jsulmJ JonBJ 2 Replies Last reply
        0
        • D delos

          Hi

          Usually Germans assemble long sentences ;-) So thanks for the quick and short answers.
          At what point should I call "raise()"? I want the main window to pop into the front when I click on it.

          Cheers
          delos

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

          @delos said in Move dialogs behind main window when it is clicked:

          I want the main window to pop into the front when I click on it

          If your dialog is not modal then it should already be the case? If dialog is modal then you can't raise main window above it as it is modal.

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

          1 Reply Last reply
          1
          • D delos

            Hi

            Usually Germans assemble long sentences ;-) So thanks for the quick and short answers.
            At what point should I call "raise()"? I want the main window to pop into the front when I click on it.

            Cheers
            delos

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

            @delos
            As I & @jsulm said, I'm not sure you can raise another window on top of a modal. For playing about though, Qt does have some "always on top" window flag (setWindowFlags(Qt::WindowStaysOnTopHint), then show()), you might be able to apply that temporarily to your main window and clear it later on, you'd have to test.

            1 Reply Last reply
            1
            • D delos

              Hi

              I have a main Window (QMainWindow) with charts inside and the possibility to open a dialog that can modify the contents (data) of the chart.
              It works fine with a QDialog. Though, when I change a value inside the dialog, I would like to see what happens in the main window. Of course I can move the dialog away with the mouse so I can see the whole main window or chart, respectively.
              Some users might not have the space on their desktop, though. Therefore, it would be nice to move the main window to the front when it is clicked.
              Up to now I tried to play with the "modal" flag of both windows and the "show()" method. None of them brings the dialog in the background when I chose the main window.
              Is there some flag that can be set to achieve that?
              I am using Qt creator and Windows 10.

              Best regards
              delos

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

              @delos
              Assuming the above does not work, as I suspect.

              First of all, it's "unusual" (in my experience) to have actions on a modal dialog have any effect on any other window. Usually a modal dialog allows user to type stuff in but does nothing till they accept the whole dialog.

              But if you want to do this: given your potential lack of user space to drag the modal somewhere, I would expect the dialog to have the window button furniture which has the "Minimize" button on it (and/or possibly allow resizing to shrink size). It will still obscure your other window while the user types stuff in, but it would allow the dialog to be minimized so that the user can see what's behind it. It can still remain modal, so the user has to finish interacting with it before he can do anything else.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                delos
                wrote on last edited by
                #9

                Thanks

                Just tried it but won't work. Is there something else but a QDialog that would react the way I want it to?

                Cheers
                delos

                JonBJ 1 Reply Last reply
                0
                • D delos

                  Thanks

                  Just tried it but won't work. Is there something else but a QDialog that would react the way I want it to?

                  Cheers
                  delos

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

                  @delos
                  Would what I've just typed in be acceptable to users, because that's pretty simple...?

                  Otherwise, make the dialog modeless, then you can do what you want.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    delos
                    wrote on last edited by
                    #11

                    Not really ;-)screen.PNG
                    I got spin buttons, text entries and check boxes in the dialog. E.g. when I press a spin button, they should see who the graph changes. It's changing parameters of some formula that will affect the plot.
                    What I will do now is moving the dialog just below the main window and see what they say. Depends on the size of their screen.

                    regards
                    delos

                    JonBJ 1 Reply Last reply
                    0
                    • D delos

                      Not really ;-)screen.PNG
                      I got spin buttons, text entries and check boxes in the dialog. E.g. when I press a spin button, they should see who the graph changes. It's changing parameters of some formula that will affect the plot.
                      What I will do now is moving the dialog just below the main window and see what they say. Depends on the size of their screen.

                      regards
                      delos

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

                      @delos
                      Good luck. But for behaviour you want I cannot see why you would that dialog to be modal, it should be modeless, and then user can click between. And you don't choose to have the "Minimize" furniture I suggested, also up to you.

                      Another possibility, which I think is what I would do: don't have those settings on a dialog at all. Make your window have a split-pane, those parameters in the bottom pane, panes resizeable vertically, also scrollbar on at least bottom pane so it can be as small as desired.. As they get changed, graph in top area gets redrawn. That's the interface I'd expect. Plenty of (Windows) apps do that. Press F12 in your web browser for Developer Tools and see how they do this kind of thing (you can make changes in bottom pane and see reflected in top pane).

                      1 Reply Last reply
                      2

                      • Login

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