Recent

Author Topic: QT fileselection window stays on-screen  (Read 1013 times)

wschulte

  • New Member
  • *
  • Posts: 39
QT fileselection window stays on-screen
« on: March 29, 2026, 02:34:02 pm »
Working with an application that processes spreadsheets, I noticed a very annoying effect. What happens is as follows:
1 the file with the spreadsheet is selected using the TOpenDialog
2 TOpenDialog is destroyed
3 file is processed
I would expect that the dialog is removed from the screen after step 2. What happens is that it stays on screen until step 3 ends. That is very annoying as the user has the impression nothing happens.
I attach an example. The original window is maximized so you can see that the cursor is really changed by moving the cursor out from the file selection window. This happens on QT5 (5.15.13) as well as on QT6 (6.4.2).
In GTK2 the fileselection window disappears instantly in step 2, albeit .. there the cursor doesn't change  :o

But one thing at a time: why doesn't the fileselection window disappear ? What am i doing wrong.
Compile the attached example under the different widget sets and see for yourself. Oh .. in the window the actual widget set is mentioned.

Linux Mint 22.3 Zena, Cinnamon v: 6.6.7
Lazarus 4.4
Freepascal 3.2.2
« Last Edit: March 29, 2026, 02:36:59 pm by wschulte »

cdbc

  • Hero Member
  • *****
  • Posts: 2726
    • http://www.cdbc.dk
Re: QT fileselection window stays on-screen
« Reply #1 on: March 29, 2026, 03:23:50 pm »
Hi
Quote
1 the file with the spreadsheet is selected using the TOpenDialog
2 TOpenDialog is destroyed
3 file is processed
Instead try this:
  • the file with the spreadsheet is selected using the TOpenDialog
  • TOpenDialog is destroyed
  • Application.ProcessMessages;
  • file is processed
That should releive you of that problem...
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

wschulte

  • New Member
  • *
  • Posts: 39
Re: QT fileselection window stays on-screen
« Reply #2 on: March 29, 2026, 03:28:01 pm »
Instead try this:
  • the file with the spreadsheet is selected using the TOpenDialog
  • TOpenDialog is destroyed
  • Application.ProcessMessages;
  • file is processed
That should releive you of that problem...
HTH
Regards Benny

Hi Benny,
That was my thought also, but it brought no change. Tried processmessages at different point, but the fileselection window stays on screen.

zeljko

  • Hero Member
  • *****
  • Posts: 1906
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QT fileselection window stays on-screen
« Reply #3 on: March 29, 2026, 08:54:42 pm »
Probably because of Qt's gtk3 dialogs hook if it runs under some gtk2/gtk3 wm, and cinnamon actually is one of such. Try to run your app on KDE in native Qt environment and see if that matters.

wschulte

  • New Member
  • *
  • Posts: 39
Re: QT fileselection window stays on-screen
« Reply #4 on: March 30, 2026, 09:16:57 am »
Probably because of Qt's gtk3 dialogs hook if it runs under some gtk2/gtk3 wm, and cinnamon actually is one of such. Try to run your app on KDE in native Qt environment and see if that matters.

Mmmm, that could be the case. I know that on my system filedialogs almost always run in a "nemo" like shell. I will give the KDE a try, but i have to build a virtual for that.
But despite this I see no reason why the window wouldn't be destroyed in time. A bug?

zeljko

  • Hero Member
  • *****
  • Posts: 1906
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: QT fileselection window stays on-screen
« Reply #5 on: March 30, 2026, 11:38:22 am »
If it's bug then it is in Qt library. Try to use non native dialogs (afair there's define in qtdefines.inc probably), enable it so Qt uses it's own dialogs and then test, if that works, than it's definitelly problem with Qt library and gtk3 dialogs handling, so only some kinda of workaround can help.

wschulte

  • New Member
  • *
  • Posts: 39
Re: QT fileselection window stays on-screen
« Reply #6 on: March 31, 2026, 04:40:39 pm »
Probably because of Qt's gtk3 dialogs hook if it runs under some gtk2/gtk3 wm, and cinnamon actually is one of such. Try to run your app on KDE in native Qt environment and see if that matters.

Ok, tried it on Fedora 43. Took me something, but indeed: the fileselection window disappears right after the click, so the underlying window is visible again.
Annoying enough the cursor isnt changed  :o

« Last Edit: April 01, 2026, 08:19:46 am by wschulte »

wschulte

  • New Member
  • *
  • Posts: 39
Re: QT fileselection window stays on-screen
« Reply #7 on: March 31, 2026, 04:48:11 pm »
If it's bug then it is in Qt library. Try to use non native dialogs (afair there's define in qtdefines.inc probably), enable it so Qt uses it's own dialogs and then test, if that works, than it's definitelly problem with Qt library and gtk3 dialogs handling, so only some kinda of workaround can help.

Now it becomes a bit weird. If I add "-dQT_NATIVE_DIALOGS" to the compilation path (Project Options -> Compiler options -> Custom options) nothing happens  :(. It doesnt work.
When I include it in the qtdefines.inc file (in lcl/interfaces/qt5) it .. works  :D even the cursor changes as desired. Well .. that is only the first time you choose a file  >:(; a 2nd time choosing reverts tp the old behavious. If you want it again you have to end the program and start it again.

The last described behavior is weird ...

This was on the Linux mint cinnamon

PS. What amazes me is that I always see a filedialog that look very "nemo" like. Not what I am used to, from QT programs. And defnitely totally different from what I see on Fedora.
« Last Edit: April 01, 2026, 04:04:33 pm by wschulte »

 

TinyPortal © 2005-2018