Search code examples
c++user-interfacedialogcross-platformnative

cross platform native open/save file dialogs


I'm writing a UI for my program using opengl with SDL in a combination of Lua and C++

What I need now is some library that will allow me to call a function that presents the user with a file select dialog for opening/saving a file. But if the OS offers native functionality for such a dialog, then I want to use that dialog (eg Window's GetOpenFileName).

The only platforms I need to support are Windows and Linux, but I want to be able to still use most of the SDL & openGL code I've already written.

What options are available?


Solution

  • In my opinion, wxWidgets is the open source, battle tested, mature, cross platform, cross language, free, open source, GUI library. Beside wxWidgets, there are also many other such cross platform libraries, such as:

    ... and more.

    You will most likely find you're looking for in the AbiWord source code. Look for "FileOpen" inside the src directory:

    ./af/xap/cocoa/xap_CocoaDlg_FileOpenSaveAs.cpp
    ./af/xap/cocoa/xap_CocoaDlg_FileOpenSaveAs.h
    ./af/xap/cocoa/xap_CocoaFileOpen_Views.nib
    ./af/xap/cocoa/xap_CocoaFileOpen_Views.nib/classes.nib
    ./af/xap/cocoa/xap_CocoaFileOpen_Views.nib/info.nib
    ./af/xap/cocoa/xap_CocoaFileOpen_Views.nib/keyedobjects.nib
    ./af/xap/gtk/xap_UnixDlg_FileOpenSaveAs.cpp
    ./af/xap/gtk/xap_UnixDlg_FileOpenSaveAs.h
    ./af/xap/win/xap_Win32Dlg_FileOpenSaveAs.cpp
    ./af/xap/win/xap_Win32Dlg_FileOpenSaveAs.h
    ./af/xap/xp/xap_Dlg_FileOpenSaveAs.cpp
    ./af/xap/xp/xap_Dlg_FileOpenSaveAs.h
    

    The Windows version does indeed use GetOpenFileName().


    Of course, as Andre points out while downvoting a valid alternative answer, there's also Qt, as you already know. Refer to raj's answer for a link.