Unsolved Move dialogs behind main window when it is clicked
-
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 -
@delos Why not calling https://doc.qt.io/qt-5/qwidget.html#raise on main window?
-
@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 ;-)
-
@JonB Germans say: "In der Kürze liegt die Würze" :-D
English: "Brevity is the soul of wit" -
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 -
@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.
-
@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)
, thenshow()
), you might be able to apply that temporarily to your main window and clear it later on, you'd have to test. -
@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.
-
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 -
@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.
-
Not really ;-)
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 -
@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).