2

I've been away from GUI programming for quite some time so please pardon my ignorance.

I would like to attempt the following:

  • Write a Mac OSX app but still be able to port to Win/Linux (i.e. C++ core with Obj-C GUI)
  • Avoid Qt/other toolkits on OSX (i.e. talk to Cocoa directly - I feel that many Qt apps I use stick out like sore thumbs compared to the rest of my system)
  • Not as important, but it would be nice to avoid Visual Studio if it means I can have the freedom to use newer C++ features even on Windows if they help create better code.

I believe this configuration might get me what I'm looking for:

  • Core C++ Static Library
  • OSX GUI (Cocoa)
  • Windows GUI (Qt+MinGW?) OR (no new C++ features, Visual Studio + ManagedC++/C#/????)
  • Linux GUI (Qt)

Once again, sorry for my ignorance but is this possible? Is this sane? Are there any real-world open source examples accomplish something like this?

Hugh Young
  • 98
  • 7
  • if C# then why not Java + Swing (extremly cross platform) or Java FX? Or SWL/JFace (native controls, DLL required) – Jacek Cz Sep 21 '15 at 04:52

2 Answers2

5

There is quite a few OS X applications that have completely custom-designed looks that don't use very many stock controls. iStat Menus comes to mind, but there are many other examples. They still look good, but it's done by manually designing them to look good and to "mesh" with the overall look of OS X applications. Even their preferences pane doesn't use stock buttons.

Thus, you can go quite far using Qt, you just have to pay close attention to what you're doing - similarly to the way other developers are paying close attention even when using Cocoa. You'll find that Qt's controls offer functionality often above and beyond what's offered in Cocoa.

That said, on OS X sometimes you may need to run some native code that expects a CFRunLoop to be present. It's good to know that Qt's event loop already spins a runloop for you, so as long as you have an event loop spinning in a given thread, you can use runloop-based code - the default runloop is provided by Qt's implementation of QEventDispatcher (somewhere in its guts). For non-gui threads, the unmodified QThread does it for you. This is useful for using asynchronous IOKit functionality, for example. Another answer of mine presents some Cocoa mouse event grabbing code. A previous version that used Carbon can be found in the edit history of that answer.

Same goes for Windows: Qt runs a message sink for all top-level windows it owns, and you can integrate native controls/windows using qtwinmigrate. You can also integrate ActiveX controls using the Active Qt framework.

Community
  • 1
  • 1
Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • Thanks, especially for all of the time-saving information for the future. Now that I think about it I do notice that some of my favourite GUIs don't overdo the native controls. Glad to know I can feel safe using Qt. – Hugh Young Oct 30 '13 at 03:42
3

Well I think you should try Qt even on OSX. Qt allows native/custom look of applications (those cases you mentioned are probably bad examples - you probably haven't noticed that lots of other applications also use Qt).

Tools I usually use for multi-platform development:

  • C++ (now C++11 since all major compilers more or less support it)
  • Boost
  • Qt
  • CMake as build system generator

If you use this tool-set you can choose whichever platform you like for development and still be multi-platform without extensive work on the other platforms.

Johny
  • 1,947
  • 13
  • 23