Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a GUI for a large cross-platform C++ project?

Tags:

I have a large cross-platform (Linux and Windows) C++ project, for which I want to create a GUI.

I have few very general questions about the basic principles of GUI for such project:

  1. Should the GUI be separated from the application's logic?
  2. If it is separated, how should the logic and the GUI communicate? Are TCP/IP sockets a good option? What are other possibilities?
  3. Is it a good idea to have the GUI in a language different than a C++? If yes - which language?
  4. Is it a good idea to have a browser-based GUI?
  5. Even though the project's core logic is cross-platform, I can decide that the GUI will be only Windows-based (.NET?) and it will communicate with the logic on the relevant Win/Linux machine through Socket or similar method. Is it a good idea to do so?
like image 883
Igor Avatar asked Feb 03 '10 12:02

Igor


People also ask

Is C good for GUI programming?

All operating systems are written in C. So, any application, console/GUI you write in C is the standard way of writing for the operating system.

Does C++ have a GUI?

The C++ standard library does not contain any GUI functions as Java or C# do, but there are many useful external libraries that you can install.


1 Answers

  1. Should the GUI be separated from the application's logic?

    Yes, definitely....

  2. If it is separated, how should the logic and the GUI communicate? Are TCP/IP sockets a good option? What are other possibilities?

    ...but not that much. Sockets would be overkill (exception: see question 5). Usually you split up the classes in GUI and backend parts. The GUI classes then call methods of the backend.

  3. Is it a good idea to have the GUI in a language different than a C++? If yes - which language?

    If so, you would have to integrate the two languages, so I would recommend writing everything in the same language. But to answer your question, you could for example create Python bindings for your backend and write the GUI in Python (with PyGTK, PyQT or wxWidgets).

  4. Is it a good idea to have a browser-based GUI?

    That depends on how you want to deploy your application. If it should be installed on each client computer, a web interface doesn't make sense. If you want to host it centrally, then you might opt for a web interface.

  5. Even though the project's core logic is cross-platform, I can decide that the GUI will be only Windows-based (.NET?) and it will communicate with the logic on the relevant Win/Linux machine through Socket or similar method. Is it a good idea to do so?

    I think this makes sense only if the backend must be some kind of secure (i.e. must not be installed on users' computers) or if you have a thin client-like approach as in question 4. Writing cross-platform GUIs is much easier than writing cross-platform backends (in my opinion), so you should rather do both parts cross-platform. By the way, .NET-based GUIs are not Windows-only - Mono already supports a great subset of Windows Forms, for example (but not WPF, sadly).

EDIT:

Concerning your Mono question: Mono is mostly stable, but not everything is yet implemented. To be sure, you can run The Mono Migration Analyzer (MoMA) to find out if something will not work in Mono. But I think the fact that so many companies are successfully using Mono in production environments means that you should at least consider Mono as an option!

like image 117
AndiDog Avatar answered Sep 19 '22 07:09

AndiDog