Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ simple open file dialog in linux

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.

like image 206
user2805119 Avatar asked Sep 22 '13 21:09

user2805119


People also ask

What is Open File dialog?

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.

How do I open the dialog box in Visual Basic?

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.


1 Answers

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.

like image 188
Ziming Song Avatar answered Sep 20 '22 21:09

Ziming Song