QfileDialog, getSaveFileName crash

736 views
Skip to first unread message

Luigi Ferraris

unread,
Nov 20, 2015, 8:50:06 AM11/20/15
to QtContribs
Hi Pritpal,
next code works fine
cPath := QFileDialog():getExistingDirectory( oParent, ;
                                             "Choose Directory", ;
                                             cPath, ;
                                             hb_BitOr( QFileDialog_ShowDirsOnly, QFileDialog_DontResolveSymlinks, QFileDialog_DontUseNativeDialog ) )



Then I have used next code
cFile := QFileDialog():getSaveFileName( oParent, ;
                                        "Save File", ;
                                        cFile, ;
                                        "Files (*.txt)", ;
                                        "", ; (1)read below
                                        QFileDialog_DontUseNativeDialog )


but it crash the program (hb_out_log created)

Using next works fine
cFile := QFileDialog():getSaveFileName( oParent, ;
                                        "Save File", ;
                                        cFile, ;
                                        "Files (*.txt)" )
but it shows dialog using the native dialog style and I don't want it.

Problem seems related with (1) parameter; using next values I get :
NIL, error parameter
a number, error parameter
"" (string), crash program when dialog closed

Regards
Luigi Ferraris

Zoran Sibinovic

unread,
Nov 20, 2015, 8:56:58 AM11/20/15
to QtContribs
Hi Luigi,

I'm haveing problem with QFileDialog() to mine is that it not opens the right filediaog unbder XP if you 
write the code to get only the directory file dialog.

In the meantime I found this text that may be useful to solve your problem.

QFileDialog::DontUseNativeDialog0x00000010Don't use the native file dialog. By default, the native file dialog is used unless you use a subclass of QFileDialog that contains theQ_OBJECT macro, or the platform does not have a native dialog of the type that you require.
  Zoran

Zoran Sibinovic

unread,
Nov 20, 2015, 8:58:03 AM11/20/15
to QtContribs
Sorry for text mistakes,

prooblem with the keyboard.

Zoran

Luigi Ferraris

unread,
Nov 20, 2015, 2:27:23 PM11/20/15
to qtcon...@googlegroups.com
Il 20/11/2015 14.56, Zoran Sibinovic ha scritto:
> Hi Luigi,
>
> I'm haveing problem with QFileDialog() to mine is that it not opens
> the right filediaog unbder XP if you
> write the code to get only the directory file dialog.
>
Hi Zoran,
probably, but I'm not sure and I'm not able to use C++, can be a Qt
problem; but I repeat me: I'm not sure.

Using another Qt approach, I think you can solve on WinXp. Below a (very
simple) snipped code to setting up the dialog

LOCAL oDialog
LOCAL nButtonPressed

WITH OBJECT oDialog := QFileDialog( ... )
:setOption( QFileDialog_DontUseNativeDialog, .T. )
:setOption( QFileDialog_ShowDirsOnly, .T. )
:setFileMode( QFileDialog_Directory )
END WITH

nButtonPressed := oDialog:exec()

IF nButtonPressed == QDialog_Accepted
oQtList := QDialog:selectedFiles()
ENDIF

Regards
Luigi

Zoran Sibinovic

unread,
Nov 20, 2015, 3:48:43 PM11/20/15
to QtContribs, luigfe...@gmail.com
Hi Luigi,

What I haven't used in the code is only

:setOption( QFileDialog_DontUseNativeDialog, .T. )

will see on monday on a Xp machine and let you know

Regards
Zoran

Luigi Ferraris

unread,
Nov 21, 2015, 7:44:09 AM11/21/15
to Zoran Sibinovic, QtContribs
Il 20/11/2015 21.48, Zoran Sibinovic ha scritto:
What I haven't used in the code is only

:setOption( QFileDialog_DontUseNativeDialog, .T. )

will see on monday on a Xp machine and let you know

I'm using it and works fine on Xp and Linux :-)
Luigi

Zoran Sibinovic

unread,
Nov 24, 2015, 7:52:13 AM11/24/15
to QtContribs, zoran.s...@gmail.com, luigfe...@gmail.com
Hi Luigi,

It works nicely on XP now too

Have missed the QFileDialog_DontUseNativeDialog option

Thanks very much
Zoran
Reply all
Reply to author
Forward
0 new messages