Recent

Author Topic: Qt6 and the Save Dialog  (Read 4969 times)

Bogen85

  • Hero Member
  • *****
  • Posts: 572
Re: Qt6 and the Save Dialog
« Reply #45 on: March 01, 2023, 05:03:04 am »
@ rca

Interesting...

Code: Text  [Select][+][-]
  1. $ find /usr/lib64/qt6/plugins/platformthemes -type f
  2. /usr/lib64/qt6/plugins/platformthemes/libqgtk3.so
  3. /usr/lib64/qt6/plugins/platformthemes/libqxdgdesktopportal.so
  4. /usr/lib64/qt6/plugins/platformthemes/libqt6ct.so

Same on both Fedora 37 and AlmaLinux 9.1.

On AlmaLinux 9.1 there is no qgnomeplatform for qt6, only for qt5.
Fedora 37 has both.

I'll need to stick with libqt6ct theming/styling as AlmaLinux 9.x is my primary platform.

I've seen similar threads to this one, but with qt5.
For instance, this one: https://forum.lazarus.freepascal.org/index.php/topic,61582.0.html
Could be a related issue...

In my case the problem is that it stays in the loop, it fails indefinitely when painting the dialog.

Using @dbannon's example and his native Dialogs code the behavior is the same.

Thanks to your code I managed to verify that when using non-native Dialogs, it shows them right away without any delay.
The behavior of the native dialogs has a lot to do with the "platformthemes" installed and used.
...
With that, everything was settled for me.

All the dialogs are displayed, without delay, without any problem if they are native or not.

You are welcome.  ;D
Even though I've not had this delay issue, I've had qt5 and qt6 appearance related issues, and troubleshooting in this thread is helping me through some of those.

Failure to paint when the "how to style the painting" is not available.... Sort of makes sense...



rca

  • Jr. Member
  • **
  • Posts: 58
Re: Qt6 and the Save Dialog
« Reply #46 on: March 02, 2023, 03:56:43 pm »
I found the solution, disabling QtUseNativeEventLoop in lcl/interfaces/qt6/qtdefines.inc

Code: Pascal  [Select][+][-]
  1. {.$DEFINE QtUseNativeEventLoop}

Go back to Build Lazarus and recompile the applications.

Both the Lazarus IDE dialogs, as well as those of applications built for Qt6 now work correctly, without delay, whether they are native or not.

rca

  • Jr. Member
  • **
  • Posts: 58
Re: Qt6 and the Save Dialog
« Reply #47 on: March 06, 2023, 05:43:43 pm »
I see that the change was made to the main (trunk) branch about three months ago:
"Qt6: all platforms now use Qt native event loop."

https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/af2916c4bacea0e869e023915dfe8cec9cdd9ae3

Previously QtUseNativeEventLoop was only enabled for MacOSX cocoa 64.

And also in an issue, I read from @Željan Rikalo: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40011#note_1179754793

"Also, try to disable QtUseNativeEventLoop in lcl/interfaces/qt6/qtdefines.inc, maybe that makes problem for you. Here it works ok for lazarus IDE and any app built for Qt6."


dbannon

  • Hero Member
  • *****
  • Posts: 2445
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt6 and the Save Dialog
« Reply #48 on: March 11, 2023, 11:43:05 am »
No, I am sorry rca, there is more going on here than it appears.

disabling Qt native event loop does not solve the problem on my test setup.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

rca

  • Jr. Member
  • **
  • Posts: 58
Re: Qt6 and the Save Dialog
« Reply #49 on: March 11, 2023, 09:24:28 pm »
No, I am sorry rca, there is more going on here than it appears.

disabling Qt native event loop does not solve the problem on my test setup.

Davo

Using fedora 37 and Debian 12 with Gnome Desktop, I just had to disable QtUseNativeEventLoop.

On Debian 12, I had to install qt6-wayland.

Since by default the Gnome desktop and my applications are running on Wayland.


When Starting the Gnome desktop with Xorg (X11), the problem reappears.

rca

  • Jr. Member
  • **
  • Posts: 58
Re: Qt6 and the Save Dialog
« Reply #50 on: March 11, 2023, 09:30:29 pm »
In X11, In addition to disabling QtUseNativeEventLoop, I fixed it with:

Reading "Qt defines" from https://wiki.freepascal.org/LCL_Defines

Add to Configure "Build Lazarus", the flag -dQT_NATIVE_DIALOGS

Code: Pascal  [Select][+][-]
  1. -g -gl -dQT_NATIVE_DIALOGS -O1

The file lcl/interfaces/qt6/qtwsdialogs.pp has two errors:

Code: Pascal  [Select][+][-]
  1. qtwsdialogs.pp(472,25) Error: Identifier not found "QFileDialogDontConfirmOverwrite"
  2. qtwsdialogs.pp(546,25) Error: Identifier not found "QFileDialogReadOnly"

Change of QFileDialogDontConfirmOverwrite to QFileDialogOptionDontConfirmOverwrite

Change of QFileDialogReadOnly to QFileDialogOptionReadOnly

Rebuild your applications.

dbannon

  • Hero Member
  • *****
  • Posts: 2445
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt6 and the Save Dialog
« Reply #51 on: March 11, 2023, 11:42:23 pm »
No, I am sorry rca, there is more going on here than it appears.

disabling Qt native event loop does not solve the problem on my test setup.

Davo

Using fedora 37 and Debian 12 with Gnome Desktop, I just had to disable QtUseNativeEventLoop.

On Debian 12, I had to install qt6-wayland.

Since by default the Gnome desktop and my applications are running on Wayland.


When Starting the Gnome desktop with Xorg (X11), the problem reappears.

OK, thats interesting !  My test VM were XFCe and Mate. Be rather funny if we can get it working on Wayland only.

I have trashed those two VMs (disk space) but might, time permitting, rebuild them.

Thanks RCS, you are finding out some valuable stuff here.

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

rca

  • Jr. Member
  • **
  • Posts: 58
Re: Qt6 and the Save Dialog
« Reply #52 on: April 11, 2023, 02:27:14 am »
This behavior only affects save dialogs that are native to both Qt5 and Qt6:

Parsing the file lazarus/lcl/interfaces/qt6/qtwsdialogs.pp

Inside TQtWSOpenDialog.CreateHandle
Code: Pascal  [Select][+][-]
  1. class function TQtWSOpenDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
  2.  
  3.     {$ifndef QT_NATIVE_DIALOGS}
  4.     QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  5.       QFileDialogOptionDontUseNativeDialog, True);
  6.     FileDialog.initializePreview(TPreviewFileDialog(ACommonDialog).PreviewFileControl);
  7.     {$endif}

But inside TQtWSFileDialog.CreateHandle
Code: Pascal  [Select][+][-]
  1. class function TQtWSFileDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
  2.  
  3.   QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  4.     QFileDialogOptionDontUseNativeDialog, False);

I changed from
Code: Pascal  [Select][+][-]
  1.   QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  2.     QFileDialogOptionDontUseNativeDialog, False);

for this
Code: Pascal  [Select][+][-]
  1.   {$ifndef QT_NATIVE_DIALOGS}
  2.   QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  3.     QFileDialogOptionDontUseNativeDialog, True);
  4.   {$endif}

Rebuild Lazarus and recompile your applications.
« Last Edit: April 11, 2023, 07:53:40 pm by rca »

dbannon

  • Hero Member
  • *****
  • Posts: 2445
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt6 and the Save Dialog
« Reply #53 on: April 27, 2023, 02:10:14 pm »
Just thought I'd follow up a touch here to mark the release of Ubuntu 23.04.

On Ubuntu 23.04, Gnome (incredibly ugly by the way), using Qt6 6.4.2, problem is still there.

An app built on the above machine with today's Lazarus Main and using a freshly built libQt6pas built from todays Lazarus Main still goes off to never never land when you open a Save Dialog -

  • if there is no platform theme set.
  • if the platform theme is set to gtk2 or gtk3
  • BUT WORKS OK, as it should, if qt6ct is installed and the platform theme is set to qt6ct


So, have to conclude that this problem is not going to go away with newer versions of Qt6.

And I tried rca's tricks too, same result.

Davo

 
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

rca

  • Jr. Member
  • **
  • Posts: 58
Re: Qt6 and the Save Dialog
« Reply #54 on: May 06, 2023, 05:55:41 pm »

@Zeljko already fixed this issue. Thank you very much for your excellent work.

Save dialogs now open immediately without any delay.

zeljko

  • Hero Member
  • *****
  • Posts: 1424
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Qt6 and the Save Dialog
« Reply #55 on: May 07, 2023, 08:37:58 am »
Glad to hear that :)

dbannon

  • Hero Member
  • *****
  • Posts: 2445
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt6 and the Save Dialog
« Reply #56 on: May 08, 2023, 02:58:39 am »
No, sorry to bring bad tidings, I still see this on Ubuntu 23.04, Gnome in both Wayland and XOrg sessions. Using todays Lazarus Src.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. var
  3.     SaveExport : TSaveDialog;
  4. begin
  5.     SaveExport := TSaveDialog.Create(self);
  6.     SaveExport.DefaultExt := 'md';
  7.     SaveExport.InitialDir := '.';
  8.     SaveExport.Filename := 'blar';
  9.     if SaveExport.Execute then
  10.         showmessage(SaveExport.FileName);
  11.     SaveExport.Free;
  12. end;

Davo

Edit: zeljko, I did not build new libraries, is a rebuild necessary (from 6.2.5) ?
 
« Last Edit: May 08, 2023, 03:01:50 am by dbannon »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

rca

  • Jr. Member
  • **
  • Posts: 58
Re: Qt6 and the Save Dialog
« Reply #57 on: May 08, 2023, 04:37:53 am »
I built with the lazarus trunk version and with libQt6Pas 6.2.5

On fedora 38 with Gnome 44, work fine in both Wayland and XOrg sessions.

And I can confirm your same results on Ubuntu 23.04 with Gnome 44. (Delay in both sessions)


I have noticed that currently the systems have different version of Qt6:
  • Fedora 38, Qt6 has version: 6.5.0
  • Ubuntu 23.04, Qt6 has version: 6.4.2

Perhaps it is the reason why despite having the same Gnome 44 it does work on Fedora.

dbannon

  • Hero Member
  • *****
  • Posts: 2445
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt6 and the Save Dialog
« Reply #58 on: May 08, 2023, 09:15:25 am »
Yes, rca, that probably makes sense.

Debian has Qt6 6.4.2 in Bullseye Backports, Bookworm and even Sid. To me thats almost certain that bookworm release will be 6.4.2. A later one 'might' appear in backports later on. So, won't really know until then.

Confirmed problem also exists still in Debian Gnome as we'd expect. But, to my surprise, Debian Bookworm KDE does not exhibit the problem ! The same Qt6 6.4.2.  So, are we missing a package that gets pre-installed on KDE ?

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

 

TinyPortal © 2005-2018