Re: [Interest] Modeless dialog issue on Mac

2023-11-15 Thread Hamish Moffatt via Interest

On 15/11/23 21:01, Calogero Mauceri wrote:
The problem of using Qt::WindowStaysOnTopHint is that the dialog stays 
on top of any desktop application while it has to be on top of the 
application level only. Here is what I mean



We grappled with this too. It actually worked well in earlier versions 
of Qt (a long time ago).


We worked around it by watching for application state change events and 
dynamically removing the WindowStaysOnTop flag when the application 
loses focus.



Tor writes that this is normal behaviour on macOS, but it's not 
consistent with other Qt platforms.




Hamish

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-15 Thread Oliver Knoll


> Am 15.11.2023 um 14:02 schrieb Calogero Mauceri :
> 
> I tried the example application you suggested, it seems none of the flags 
> combination results in the wanted result:

Oh… bummer! ChatGPT sounded so convincing!

But like a (then) famous rock band was already postulating in the early 90ies: 
„Use your Hallucination“!

;)

Hope you still find a way, like the suggested workaround to directly interface 
with the native API.

Best,
  Oliver
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-15 Thread Tor Arne Vestbø via Interest
As a workaround you can try 
static_cast(window.winId()).window.windowLevel = NSNormalWindowLevel + 
1

In a .mm file or build your cpp file with -x objective-c++

On 15 Nov 2023, at 14:02, Calogero Mauceri  wrote:

You don't often get email from mauc...@actgate.com. Learn why this is 
important
Thanks Oliver for you hint,

I tried the example application you suggested, it seems none of the flags 
combination results in the wanted result: either the window is behind the main 
application or it is on top of all desktop applications

On Wed, Nov 15, 2023 at 1:25 PM Oliver Knoll 
mailto:till.oliver.kn...@gmail.com>> wrote:


Am 15.11.2023 um 13:14 schrieb Oliver Knoll 
mailto:till.oliver.kn...@gmail.com>>:

But I understand your use case better now, and yes, it is different from mine. 
However I don‘t know any „top of application (only)“ flag myself (not saying 
that Qt doesn’t provide such a flag - I just don’t know).

And what do we do if we developers are too lazy to read the fine manual? 
Exactly! We have someone else read it for us - like your favourite LLM! ;)

Here is what ChatGPT has to say about it:

https://zzzcode.ai/answer-question?id=d21e6762-84c8-406c-823c-f379471ce766

Quote: „ Yes, in Qt, there is a flag that can be used to make a modeless dialog 
stay on top of the application. This flag is called Qt::WindowStaysOnTopHint. 
By setting this flag on a modeless dialog, you can ensure that the dialog 
remains on top of all other windows in the application.“

And even better: a quick research reveals that this flag („hint“) actually 
seems to exist ;)

In fact, you can try it out right away and tell us how it went:

https://doc.qt.io/qt-6/qtwidgets-widgets-windowflags-example.html

;)

Hope that helps!
  Oliver



--
Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)
www.actgate.com

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-15 Thread Calogero Mauceri
Thanks Oliver for you hint,

I tried the example application you suggested, it seems none of the flags
combination results in the wanted result: either the window is behind the
main application or it is on top of all desktop applications

On Wed, Nov 15, 2023 at 1:25 PM Oliver Knoll 
wrote:

>
>
> Am 15.11.2023 um 13:14 schrieb Oliver Knoll :
>
> But I understand your use case better now, and yes, it is different from
> mine. However I don‘t know any „top of application (only)“ flag myself (not
> saying that Qt doesn’t provide such a flag - I just don’t know).
>
>
> And what do we do if we developers are too lazy to read the fine manual?
> Exactly! We have someone else read it for us - like your favourite LLM! ;)
>
> Here is what ChatGPT has to say about it:
>
> https://zzzcode.ai/answer-question?id=d21e6762-84c8-406c-823c-f379471ce766
>
> Quote: „ Yes, in Qt, there is a flag that can be used to make a modeless
> dialog stay on top of the application. This flag is called
> Qt::WindowStaysOnTopHint. By setting this flag on a modeless dialog, you
> can ensure that the dialog remains on top of all other windows in the
> application.“
>
> And even better: a quick research reveals that this flag („hint“) actually
> seems to exist ;)
>
> In fact, you can try it out right away and tell us how it went:
>
> https://doc.qt.io/qt-6/qtwidgets-widgets-windowflags-example.html
>
> ;)
>
> Hope that helps!
>   Oliver
>
>

-- 
Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)
www.actgate.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-15 Thread Oliver Knoll


> Am 15.11.2023 um 13:14 schrieb Oliver Knoll :
> 
> But I understand your use case better now, and yes, it is different from 
> mine. However I don‘t know any „top of application (only)“ flag myself (not 
> saying that Qt doesn’t provide such a flag - I just don’t know).

And what do we do if we developers are too lazy to read the fine manual? 
Exactly! We have someone else read it for us - like your favourite LLM! ;)

Here is what ChatGPT has to say about it:

https://zzzcode.ai/answer-question?id=d21e6762-84c8-406c-823c-f379471ce766

Quote: „ Yes, in Qt, there is a flag that can be used to make a modeless dialog 
stay on top of the application. This flag is called Qt::WindowStaysOnTopHint. 
By setting this flag on a modeless dialog, you can ensure that the dialog 
remains on top of all other windows in the application.“

And even better: a quick research reveals that this flag („hint“) actually 
seems to exist ;)

In fact, you can try it out right away and tell us how it went:

https://doc.qt.io/qt-6/qtwidgets-widgets-windowflags-example.html

;)

Hope that helps!
  Oliver

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-15 Thread Oliver Knoll

> Am 15.11.2023 um 11:01 schrieb Calogero Mauceri :
> 
> The problem of using Qt::WindowStaysOnTopHint is that the dialog stays on top 
> of any desktop application

Yes, that‘s exactly the intention of this flag and that is exactly the use case 
of my application („Sky Dolly“ (open source) is a flight recorder that can - 
optionally - „stay on top“ of all other desktop applications, specifically MS 
Flight Simulator that often is running in „full screen“).

But I understand your use case better now, and yes, it is different from mine. 
However I don‘t know any „top of application (only)“ flag myself (not saying 
that Qt doesn’t provide such a flag - I just don’t know).

Cheers,
  Oliver
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-14 Thread Tor Arne Vestbø via Interest
A non-modal Dialog (NSPanel) isn’t inherently at a higher window level than a 
normal window on macOS:


[developer-og.jpg]
NSWindowLevel | Apple Developer 
Documentation
developer.apple.com

We could potentially work around it by using a non-standard window level, but 
it might have unforeseen consequences.

I recommend using the Qt::WindowStaysOnTopHint as a workaround.

Tor Arne


On 14 Nov 2023, at 18:55, Oliver Knoll  wrote:



Am 14.11.2023 um 16:29 schrieb Calogero Mauceri :


Here "this" is a pointer to the parent dialog. I've tried with QMainWindow too 
as a parent, but unfortunately the problem is still there, not sure if that's 
another bug.
The only way I found for having the modeless dialog on top of its parent is to 
create it with Qt::Tool flag.

You don‘t need to create a „tool window“: any QWidget (QWindow?) based window 
should do.

From the top of my head there should exist an „always on top“ window flag. Pass 
this to the constructor of your QDialog, refer to the Qt docs wrt „window 
flags“ (or similar).

I definitively managed to keep a QMainWindow „always on top“ with this approach 
(Win/Mac/Linux), but I expect this to work with QDialogs, too.

Best,
 Oliver
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-14 Thread Oliver Knoll


> Am 14.11.2023 um 16:29 schrieb Calogero Mauceri :
> 
> 
> Here "this" is a pointer to the parent dialog. I've tried with QMainWindow 
> too as a parent, but unfortunately the problem is still there, not sure if 
> that's another bug.
> The only way I found for having the modeless dialog on top of its parent is 
> to create it with Qt::Tool flag.

You don‘t need to create a „tool window“: any QWidget (QWindow?) based window 
should do. 

From the top of my head there should exist an „always on top“ window flag. Pass 
this to the constructor of your QDialog, refer to the Qt docs wrt „window 
flags“ (or similar).

I definitively managed to keep a QMainWindow „always on top“ with this approach 
(Win/Mac/Linux), but I expect this to work with QDialogs, too.

Best,
  Oliver
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-14 Thread Calogero Mauceri
Here "this" is a pointer to the parent dialog. I've tried with QMainWindow
too as a parent, but unfortunately the problem is still there, not sure if
that's another bug.
The only way I found for having the modeless dialog on top of its parent is
to create it with Qt::Tool flag.
That problem is only happening on Mac, it is properly working both on
Windows and Linux.

On Tue, Nov 14, 2023 at 4:22 PM Frank Osterfeld 
wrote:

>
>
> > On 14. Nov 2023, at 11:49, Calogero Mauceri  wrote:
> >
> > Hi all,
> >
> > I have the following problem with dialogs on the Mac.
> >
> > I have a main window/dialog and I am opening a modeless dialog, I need
> to have both the main window/dialog and the modeless dialog visible at the
> same time.
> > I create the modeless dialog as simple as this
> >
> > QDialog* myDialog = new QDialog(this);
>
> What is “this” here? The main window? I’ve seen these problems (unexpected
> window stacking) on Mac more than elsewhere when no parent/the wrong parent
> was passed, but can’t remember seeing it when passing the main window.
> (Haven’t done much macOS/Widget development recently though)
>
> —
> Frank Gonçalves Osterfeld | frank.osterf...@kdab.com | Senior Software
> Engineer & Teamlead
> KDAB (Deutschland) GmbH, a KDAB Group Company
> Tel: +49-30-521325470
> KDAB - The Qt, C++ and OpenGL Experts
>


-- 
Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)
www.actgate.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-14 Thread Frank Osterfeld via Interest


> On 14. Nov 2023, at 11:49, Calogero Mauceri  wrote:
> 
> Hi all,
> 
> I have the following problem with dialogs on the Mac.
> 
> I have a main window/dialog and I am opening a modeless dialog, I need to 
> have both the main window/dialog and the modeless dialog visible at the same 
> time.
> I create the modeless dialog as simple as this
> 
> QDialog* myDialog = new QDialog(this);

What is “this” here? The main window? I’ve seen these problems (unexpected 
window stacking) on Mac more than elsewhere when no parent/the wrong parent was 
passed, but can’t remember seeing it when passing the main window. (Haven’t 
done much macOS/Widget development recently though)

— 
Frank Gonçalves Osterfeld | frank.osterf...@kdab.com | Senior Software Engineer 
& Teamlead
KDAB (Deutschland) GmbH, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-14 Thread Calogero Mauceri
Thanks,

https://bugreports.qt.io/browse/QTBUG-119129

On Tue, Nov 14, 2023 at 1:09 PM Tor Arne Vestbø 
wrote:

> The broken button rendering is a bug, please file one in JIRA, thanks :)
>
> On 14 Nov 2023, at 11:49, Calogero Mauceri  wrote:
>
> Hi all,
>
> I have the following problem with dialogs on the Mac.
>
> I have a main window/dialog and I am opening a modeless dialog, I need to
> have both the main window/dialog and the modeless dialog visible at the
> same time.
> I create the modeless dialog as simple as this
>
> QDialog* myDialog = new QDialog(this);
> [...]
> myDialog->show();
> myDialog->raise();
> myDialog->activateWindow();
>
> The problem I'm having is that if I click on the main window then the
> dialog disappears behind the main application window.
> The workaround I've found is to create the dialog as a tool dialog. In
> that case the dialog stays always on top of the main application window,
> but there are some issues with the modeless dialog default button rendering
> when the dialog loses focus as visible in the following image where the
> default button in the first one.
>
> 
>
> I created a very sample application that opens both a "standard" dialog
> and a tool dialog, here are both issues in a screenshot
>
> 
>
>
> The standard dialog is behind the main application, while the tool dialog
> default button is not properly rendered when the tool dialog loses focus.
>
> Is there any workaround? Is this a Qt bug?
> Attached is the code for the above example.
> The example works fine on windows, with both types of dialogs.
>
> --
> Calogero Mauceri
> Software Engineer
>
> Applied Coherent Technology Corporation (ACT)
> www.actgate.com
> 
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
>
>

-- 
Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)
www.actgate.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Modeless dialog issue on Mac

2023-11-14 Thread Tor Arne Vestbø via Interest
The broken button rendering is a bug, please file one in JIRA, thanks :)

On 14 Nov 2023, at 11:49, Calogero Mauceri  wrote:

Hi all,

I have the following problem with dialogs on the Mac.

I have a main window/dialog and I am opening a modeless dialog, I need to have 
both the main window/dialog and the modeless dialog visible at the same time.
I create the modeless dialog as simple as this

QDialog* myDialog = new QDialog(this);
[...]
myDialog->show();
myDialog->raise();
myDialog->activateWindow();

The problem I'm having is that if I click on the main window then the dialog 
disappears behind the main application window.
The workaround I've found is to create the dialog as a tool dialog. In that 
case the dialog stays always on top of the main application window, but there 
are some issues with the modeless dialog default button rendering when the 
dialog loses focus as visible in the following image where the default button 
in the first one.



I created a very sample application that opens both a "standard" dialog and a 
tool dialog, here are both issues in a screenshot




The standard dialog is behind the main application, while the tool dialog 
default button is not properly rendered when the tool dialog loses focus.

Is there any workaround? Is this a Qt bug?
Attached is the code for the above example.
The example works fine on windows, with both types of dialogs.

--
Calogero Mauceri
Software Engineer

Applied Coherent Technology Corporation (ACT)
www.actgate.com
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest