Recent

Author Topic: [solved] Qt6 and the Save Dialog  (Read 16804 times)

dbannon

  • Hero Member
  • *****
  • Posts: 3616
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt6 and the Save Dialog
« Reply #30 on: February 28, 2023, 12:52:42 am »
OK, its not related to where the libQt6Pas library is built, I just built it on my Bookworm box (with Qt6 6.4.2) and see same problem.

Still works perfectly with qt6ct in the loop, indefinite fail to paint dialog without qt6ct.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #31 on: February 28, 2023, 01:20:41 am »
Code: Pascal  [Select][+][-]
  1. QT_QPA_PLATFORMTHEME=qt6ct  ./TestQt6  <enter>

Bogen85, do you have a Qt platform theme set to use qt6ct ?  That might explain why it works for you....

Overall, I don't think its a solution to add qt6ct as a dependency and requiring its use. That will interfere with other apps the end user might be using, and, really, is a bit hacky....

Not explicitly. I do have qt6ct installed and I do set it explicitly sometimes, but did not for this.
I uninstalled it.
It still works on Fedora on AlmaLinux. (after uninstalling qt6ct and renaming the config)

Oh, on Fedora I was using libqt6pas both from your packages and from ones built on AlmaLinux.
So, works with both your packages and ones built on AlmaLinux (without qt6ct in the mix)



dbannon

  • Hero Member
  • *****
  • Posts: 3616
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Qt6 and the Save Dialog
« Reply #32 on: February 28, 2023, 06:09:37 am »
Hmm, we have eliminated all the likely reasons. All thats left is -

  • The bug was reintroduced between 6.3 and 6.4 - unlikely but possible. And, actually, I think the bug is different now, its a fail to paint but before it was a delay before paint. Maybe its a whole new bug ?
  • There is something else, some other library for example installed in some systems but not others. My initial decision that it worked was based on a Bookworm LXQt box, I trashed that VM to save some diskspace, looks like I need to rebuild it and to get a Fedora one working too ?


Hmm, Alma is based on RedHat or Fedora ? I thought it was a "replacement" for CentOS but a quick read seems to indicate its a Fedora clone ??

Davo

Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #33 on: February 28, 2023, 06:23:22 am »
Hmm, Alma is based on RedHat or Fedora ? I thought it was a "replacement" for CentOS but a quick read seems to indicate its a Fedora clone ??

AlmaLinux is built from RHEL sources, just like CentOS was.

And RHEL releases are loosely based on a stabilized snapshot of some Fedora release. Though likely a bit more involved than just simply that, I don't know all the details.

The bug was reintroduced between 6.3 and 6.4 - unlikely but possible. And, actually, I think the bug is different now, its a fail to paint but before it was a delay before paint. Maybe its a whole new bug ?

All I know for me is that with Fedora 37 (Qt 6.4.2) and AlmaLinux 7.1 (Qt 6.3.1) both work fine.

Well, I tried both QFileDialog_getSaveFileName and QFileDialog_getOpenFileNames with and without QFileDialogOptionDontUseNativeDialog on both 6.3.1 and 6.4.2 and the delay is insignificant.

QFileDialogOptionDontUseNativeDialog did change the dialog appearance.

The only libqt6pas packages I've tried for the above was the ones from https://github.com/davidbannon/libqt6pas/releases (latest, 6.2.5) and ones I built myself with a current clone from https://github.com/davidbannon/libqt6pas on AlmaLinux 9.1
I saw no difference between the two.


I used the AlmaLinux 9.1 built packages because I was running into problems building libqt6pas on Fedora 37. I may dive into that later, but for now I don't consider that a relevant issue.

EDIT: 6.3.1, not 6.2.1
« Last Edit: February 28, 2023, 06:46:43 am by Bogen85 »

rca

  • Full Member
  • ***
  • Posts: 118
Re: Qt6 and the Save Dialog
« Reply #34 on: February 28, 2023, 01:37:20 pm »
I have Fedora 37 (Workstation Edition with Gnome), and I built libqt6pas with no problem.

But Dialogs only work for me when I install qt6ct.

And tried without installing qt6ct, assigning different environment variables, but without any success.

What does qt6ct do to the system with "Standard dialogs: Default"?

Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #35 on: February 28, 2023, 01:57:50 pm »
I have Fedora 37 (Workstation Edition with Gnome), and I built libqt6pas with no problem.

Must have been a PEBKAC situation than on my setup.
I started over again with building libqt6pas, this time worked (the building of the library and packages, installing the packages, and rebuilding and running my examples)

But Dialogs only work for me when I install qt6ct.

And tried without installing qt6ct, assigning different environment variables, but without any success.

And when you uninstall it stops working again?
For me, as I said, having qt6ct installed has no effect.

What does qt6ct do to the system with "Standard dialogs: Default"?

For me when I use "QT_QPA_PLATFORMTHEME=qt6ct" with a non native dialog I get the qt6ct look.
Without the export, the default look.

I'll post my examples shortly (the ones using libqt6pas directly without LCL in the mix).


Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #36 on: February 28, 2023, 03:59:33 pm »
Here is the code I'm testing with:

Code: Pascal  [Select][+][-]
  1. program qt_dialogs_ex1;
  2.  
  3. {$mode objfpc}
  4. {$h+}
  5.  
  6. uses
  7.   qt6;
  8.  
  9. procedure sample_files (const options: QFileDialogOptions);
  10.   var
  11.     str, title: wideString;
  12.     i:         integer;
  13.     qstr_list: QStringListH;
  14.   begin
  15.     qstr_list := QStringList_Create();
  16.  
  17.     title := 'Open these!';
  18.     QFileDialog_getOpenFileNames(qstr_list, nil, @title, nil, nil, nil, options);
  19.     for i := 0 to QStringList_size(qstr_list) - 1 do begin
  20.       QStringList_at(qstr_list, @str, i);
  21.       writeln(i + 1, ': ', str);
  22.     end;
  23.     QStringList_Destroy(qstr_list);
  24.   end;
  25.  
  26. procedure sample_save (const options: QFileDialogOptions);
  27.   var
  28.     file_name, title: wideString;
  29.   begin
  30.     title := 'Save this!';
  31.     QFileDialog_getSaveFileName(@file_name, nil, @title, nil, nil, nil, options);
  32.     writeln(file_name);
  33.   end;
  34.  
  35. procedure sample_open (const options: QFileDialogOptions);
  36.   var
  37.     file_name, title: wideString;
  38.   begin
  39.     title := 'Open this!';
  40.     QFileDialog_getOpenFileName(@file_name, nil, @title, nil, nil, nil, options);
  41.     writeln(file_name);
  42.   end;
  43.  
  44. procedure sample_dir (const options: QFileDialogOptions);
  45.   var
  46.     file_name, title: wideString;
  47.   begin
  48.     title := 'Get this!';
  49.     QFileDialog_getExistingDirectory(@file_name, nil, @title, nil, options);
  50.     writeln(file_name);
  51.   end;
  52.  
  53. procedure main;
  54.   var
  55.     app: QApplicationH;
  56.   begin
  57.     app := QApplication_create(@argc, @argv);
  58.  
  59.     if argv[1] = 'save0' then sample_save(0)
  60.     else if argv[1] = 'save1' then sample_save(QFileDialogOptionDontUseNativeDialog)
  61.     else if argv[1] = 'open0' then sample_open(0)
  62.     else if argv[1] = 'open1' then sample_open(QFileDialogOptionDontUseNativeDialog)
  63.     else if argv[1] = 'dir0' then sample_dir(0)
  64.     else if argv[1] = 'dir1' then sample_dir(QFileDialogOptionDontUseNativeDialog)
  65.     else if argv[1] = 'files0' then sample_files(0)
  66.     else if argv[1] = 'files1' then sample_files(QFileDialogOptionDontUseNativeDialog);
  67.  
  68.     QApplication_destroy(app);
  69.     writeln('Goodbye!');
  70.   end;
  71.  
  72. begin
  73.   if (argc > 1) then main
  74.   else begin
  75.     writeln('Usage: ', argv[0], ' <save0|save1|open0|open1|dir0|dir1|files0|files0>');
  76.     writeln('save0 # show save dialog using native dialog');
  77.     writeln('save1 # show save dialog not using native dialog');
  78.     writeln('open0 # show open dialog using native dialog');
  79.     writeln('open1 # show open dialog not using native dialog');
  80.     writeln('dir0 # show get directory dialog using native dialog');
  81.     writeln('dir1 # show get directory dialog not using native dialog');
  82.     writeln('files0 # show open files dialog using native dialog');
  83.     writeln('files1 # show open files dialog not using native dialog');
  84.   end;
  85. end.
  86. // CudaText: lexer_file=Pascal; tab_size=2; tab_spaces=Yes; newline=LF;

EDIT: I added open file and get directory dialog usage
« Last Edit: February 28, 2023, 04:53:54 pm by Bogen85 »

Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #37 on: February 28, 2023, 04:42:53 pm »
Seem that it's not fixed in Qt git repo. Issues about open/save file dialog are still open.

What specific Qt functions that libqtpas is using?

I looked at the bug reports you provided the links to, which is what I based my examples on.

EDIT: I added open file and get directory dialog usage to the example program (the reply previous to this one, reply #37)
« Last Edit: February 28, 2023, 05:09:20 pm by Bogen85 »

rca

  • Full Member
  • ***
  • Posts: 118
Re: Qt6 and the Save Dialog
« Reply #38 on: March 01, 2023, 12:45:29 am »
And when you uninstall it stops working again?
For me, as I said, having qt6ct installed has no effect.

It stops working immediately.

@Bogen85, I didn't manage to get your example to compile with Lazarus IDE.

However, I made an example based on your code, to test the native and non-native Open Dialogs, Save Dialogs.

Code: Pascal  [Select][+][-]
  1. unit uprdialog;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, Forms, Controls, Graphics, StdCtrls, qt6;
  9.  
  10. type
  11.  
  12.   { TForm1 }
  13.  
  14.   TForm1 = class(TForm)
  15.     Button1: TButton;
  16.     Button2: TButton;
  17.     Button3: TButton;
  18.     Button4: TButton;
  19.     procedure Button1Click(Sender: TObject);
  20.     procedure Button2Click(Sender: TObject);
  21.     procedure Button3Click(Sender: TObject);
  22.     procedure Button4Click(Sender: TObject);
  23.   private
  24.  
  25.   public
  26.  
  27.   end;
  28.  
  29. var
  30.   Form1: TForm1;
  31.  
  32. implementation
  33.  
  34. {$R *.lfm}
  35.  
  36. procedure sample_open (const options: QFileDialogOptions);
  37. var
  38.   file_name, title: wideString;
  39. begin
  40.   title := 'Open this!';
  41.   QFileDialog_getOpenFileName(@file_name, nil, @title, nil, nil, nil, options);
  42. end;
  43.  
  44. procedure sample_save (const options: QFileDialogOptions);
  45. var
  46.   file_name, title: wideString;
  47. begin
  48.   title := 'Save this!';
  49.   QFileDialog_getSaveFileName(@file_name, nil, @title, nil, nil, nil, options);
  50. end;
  51.  
  52. { TForm1 }
  53. procedure TForm1.Button1Click(Sender: TObject);
  54. begin
  55.   sample_open(0);
  56. end;
  57.  
  58. procedure TForm1.Button2Click(Sender: TObject);
  59. begin
  60.   sample_open(QFileDialogOptionDontUseNativeDialog);
  61. end;
  62.  
  63. procedure TForm1.Button3Click(Sender: TObject);
  64. begin
  65.   sample_save(0);
  66. end;
  67.  
  68. procedure TForm1.Button4Click(Sender: TObject);
  69. begin
  70.   sample_save(QFileDialogOptionDontUseNativeDialog);
  71. end;
  72.  
  73. end.
  74.    

And I find that without installing qt6ct, only non-native Dialogs work.

When installing qt6ct, they all work; but I see that really all displays them as if they were non-native dialogs.

Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #39 on: March 01, 2023, 01:38:37 am »
@Bogen85, I didn't manage to get your example to compile with Lazarus IDE.

Might be due to my compile flags and where the qt6 unit is located for me.

But I can compile it outside of my normal dev environment.

Code: Text  [Select][+][-]
  1. $ fpc qt_dialogs_ex1.pas -Fu../alt-units -Fi../include
  2. Free Pascal Compiler version 3.3.1 [2023/02/27] for x86_64
  3. Copyright (c) 1993-2023 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling qt_dialogs_ex1.pas
  6. Linking qt_dialogs_ex1
  7. 86 lines compiled, 0.7 sec, 412304 bytes code, 480896 bytes data

Code: Pascal  [Select][+][-]
  1. $ fpc qt_dialogs_ex1.pas -Fu../alt-units -Fi../include
  2. Free Pascal Compiler version 3.2.2 [2022/08/17] for x86_64
  3. Copyright (c) 1993-2021 by Florian Klaempfl and others
  4. Target OS: Linux for x86-64
  5. Compiling qt_dialogs_ex1.pas
  6. Linking qt_dialogs_ex1
  7. 86 lines compiled, 0.7 sec


When installing qt6ct, they all work; but I see that really all displays them as if they were non-native dialogs.

I see a difference if QT_QPA_PLATFORMTHEME=qt6ct is set or not.

Native and non-native seem to only have an effect if GTK3 is set for the dialog type and QT_QPA_PLATFORMTHEME=qt6ct is set.

EDIT: The GTK3 dialog is definitely different than the others.

See attached screenshots.
« Last Edit: March 01, 2023, 01:41:44 am by Bogen85 »

rca

  • Full Member
  • ***
  • Posts: 118
Re: Qt6 and the Save Dialog
« Reply #40 on: March 01, 2023, 02:11:19 am »
@Bogen85. It strikes me that it works for you with GTK3.

We both have the same Fedora 37, what do you have installed other than GTK3? or what theme did you install?

After so many tests and research, I find that the native dialogs have a lot to do with the "platformtheme" used. When I had qt6ct installed, only "Standard Dialogs: Default" worked, with the others it didn't (gtk3...).

rca

  • Full Member
  • ***
  • Posts: 118
Re: Qt6 and the Save Dialog
« Reply #41 on: March 01, 2023, 02:20:46 am »
Since the native Qt6 Dialogs with "platformtheme" GTK3 do not work for me. I must set with "gnome" for it to work.

Without having qt6ct installed, it is no longer needed. I run the application:
Code: Pascal  [Select][+][-]
  1. ./prdialog -platformtheme gnome

Code: Pascal  [Select][+][-]
  1. ./project1 -platformtheme gnome

And now it works correctly! , the difference between the dialogs that are native is displayed.

Enable it for all Qt applications, put the following command in file .bashrc:
Code: Pascal  [Select][+][-]
  1. export QT_QPA_PLATFORMTHEME=gnome

And reboot

Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #42 on: March 01, 2023, 03:29:04 am »
@Bogen85. It strikes me that it works for you with GTK3.
We both have the same Fedora 37, what do you have installed other than GTK3? or what theme did you install?

I made the screenshots with AlmaLinux 7.1, for the qt6ct theme it is "darker", that is the screenshot for qt6ct.
I'm running Xfce4 4.15.5.

But earlier I was having the same behavior with Fedora 37.
The Fedora 37 install is a VM I was actually the lxqt from several weeks back. I was seeing if lxqt would work any better for qt stuff.... Kinda... but that just made me look at qt6ct more.
I ended up putting xfce4 in the VM, and did my recent testing (my involvement in this thread) with that as well as my main AlmaLinux 7.1 install.

However, as I said, In both Fedora 37 Xfce4 and AlmaLinux 7.1 Xfce4 I get the same behavior in regard to direct usage of libqt6pas (As I have been saying in previous posts in this thread).

In Xfce4 (which is gtk3 based) I'm using Blue-Submarine and Oxygen themes, but I don't see how that is related to this. (Unless that affects gtk3 dialog setting).


Bogen85

  • Hero Member
  • *****
  • Posts: 703
Re: Qt6 and the Save Dialog
« Reply #43 on: March 01, 2023, 03:40:39 am »
Since the native Qt6 Dialogs with "platformtheme" GTK3 do not work for me. I must set with "gnome" for it to work.
...
And now it works correctly! , the difference between the dialogs that are native is displayed.

By "work" I assume you mean displays like you are configuring it to display (and that setting native/non-native in the options makes a difference)?

Enable it for all Qt applications, put the following command in file .bashrc:
Code: Pascal  [Select][+][-]
  1. export QT_QPA_PLATFORMTHEME=gnome

This might actually help me even though I'm using xfce4. I'll check.

But, even with not "working" (in regular to appearance) you are not getting the delayed viewing of dialog windows?

But the most crucial part to all of this:

I have never seen a significant delay (using libqt6pas directly), and you are saying you only get the delay when using libqt6pas indirectly via LCL in some configurations (qt qpa platformtheme related) and you also never see a delay when using libqt6pas directly?




« Last Edit: March 01, 2023, 04:05:09 am by Bogen85 »

rca

  • Full Member
  • ***
  • Posts: 118
Re: Qt6 and the Save Dialog
« Reply #44 on: March 01, 2023, 04:29:59 am »
@ Bogen85

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.

In fedora 37 (Workstation with Gnome) I have:
Code: Pascal  [Select][+][-]
  1. /usr/lib64/qt6/plugins/platformthemes/libqgnomeplatformtheme.so
  2. /usr/lib64/qt6/plugins/platformthemes/libqgtk3.so
  3. /usr/lib64/qt6/plugins/platformthemes/libqxdgdesktopportal.so

Since it's not working for me with the GTK3 platformtheme, I decided to set it to another one that has and is gnome. (QGnomePlatform)
Code: Pascal  [Select][+][-]
  1. ./prdialog -platformtheme gnome

With that, everything was settled for me.

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

 

TinyPortal © 2005-2018