I was wondering if anyone could help me out on implementing a simple file open dialog in C++ in Ubuntu. I am using OpenGL for my GUI, but I would like the user to be able to select a file when the program loads. I have tried gtkmm and wxWidgets but they seem to be too complicated for what I want to do.
OpenFileDialog component opens the Windows dialog box for browsing and selecting files. To open and read the selected files, you can use the OpenFileDialog. OpenFile method, or create an instance of the System.
In most programmes, if you click the File menu, and select the Open item, a dialogue box is displayed. From the dialogue box, you can click on a file to select it, then click the Open button.
If you just need to select a file, then launch a separate program to do that. Like @Dummy00001 said in the comment, you can start zenity --file-selection
as a child process and read its stdout.
char filename[1024];
FILE *f = popen("zenity --file-selection", "r");
fgets(filename, 1024, f);
Or you can also write your own program to do the task. That way you can customize the UI as you wish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With