user739711
user739711

Reputation: 1882

platform independent GUI

I want to make GUI for my application. It should work on multiple platforms. I want most of the code to be portable for all the OS (unix, windows, MAC).

GTK and GLib looks as a good solution. I want to use native APIs too

How to do this all??

Upvotes: 7

Views: 4717

Answers (6)

Chris Becke
Chris Becke

Reputation: 36111

I Think its worthwhile learning the native windowing layer on each platform you are targetting.

As such:

  • Cocoa
    Cocoa is the native Mac OS X windowing layer. Its an Objective-C api, but its not hard to learn, and its easy to interop with either C or C++.
  • Win32 API
    The Windows API is a C API that implements the windows native widget set.
  • GTK+
    The Unix/Linux world is more complicated as its possible to have apps written against completely different widget set implementations. You need to choose the widget set used by your target environments default desktop: If you are targeting Ubuntu then GTK+ (2) is the API to target to access the Unity desktops "native" widget set.

I don't personally like QT as they've invented their own meta compiler, making QT code (ironically) hard to port to non QT environments. QT does however present an abstraction of the native Widget set where possible.

wxWidgets is a convenient wrapper API to use as it already wraps the Win32Api, Cocoa api and GTK+ on the relevant platforms. I avoided using it however as Wx is based on Microsoft MFC - a somewhat dated Document/View C++ framework and I wanted to understand the underlying platforms.


  • Edited with some corrections wrt QT.

Upvotes: 1

asami
asami

Reputation: 803

Please take a look at Qt Framework. This will help you create cross platform GUI Applications. You would have to rely on API Offered by Qt for Native platform tasks, other wise if you proceed to use the native API's your code will not be portable.

Upvotes: 0

Alok Save
Alok Save

Reputation: 206616

You will have to implement a PAL(Platform abstraction layer).
This layer should provide a abstraction over the actual platform calls by providing interfaces which are not platform dependednt. Once you move on to another platform, only the PAL needs to be implemented for that particular platform and the rest of the application can be used as is.

Upvotes: 3

Juraj Blaho
Juraj Blaho

Reputation: 13471

Qt may be good for that.

Upvotes: 11

Henno Brandsma
Henno Brandsma

Reputation: 2166

Qt seems like an option. But if you want to use Windows API's, it will not be portable. Qt in Windows will use stuff like CreateWindow etc. but you will not. E.g. the disassembler IDA was recently rewritten in Qt and is now cross-platform.

Upvotes: 1

danron
danron

Reputation: 189

I like WxWidgets, really easy to use. It has bindings for multiple languages and you can mix it's C++ implementation with Win32 API (C code) easily.

http://www.wxwidgets.org/

A more lightweight alternative is FLTK

http://www.fltk.org/index.php

Upvotes: 5

Related Questions