Using QT to develop cross-platform applications
Using QT to develop cross-platform applications
A few years ago I did develop a network device what tracks the position of a workpiece in respect of the X-Y-Z tool position on, for instance: Mill, Lathe and/or Drill-press (DRO). The DRO spits out UDP packages with information about position, status and reads UDP packages with user commands to execute actions.
The big question was where to display the output of the DRO and I was thinking at a BeagleBone type of computer loaded with Linux. Since I am pretty fluent in a variety of computer languages and IDE’s I was thinking Eclipse or Visual Studio. After weeks of building small C++ test applications to listen to UDP packets and research using Google, I got more and more search results including QT.
Because I was more familiar with windows, I did build a small QT Win32 C++ test application listening to UDP traffic and displaying the results in a QT LCD widget. This was it, I could develop this windows application in QT half the time it would take using Eclipse or Visual Studio in a great looking graphical user interface (GUI). I did develop the windows application in roughly 6 months (nights and weekends as I have a day job).
OK, I finished the windows, but, the original idea was a Linux platform. I did set up an Oracle VirtualBox machine with Ubuntu on my windows PC and installed QT on it. Copied over the windows project to the Linux Virtualbox and compiled it without any changes and to my biggest surprise it did compile with a few warnings and it actual did run. The result was not too bad, although fonts and layouts did look pretty messed up. I did try to connect to the DRO device, but that failed because VirtualBox network settings did not map the UDP port correctly. After I changed VirtualBox’s NAT Network to a Bridged Adapter, everything started working.
The problem with fonts and layouts needed a lot of work and at the time I didn’t have a lot of experience using QT so the way I knew fixing this was not working that well. QT for Linux was not displaying my application as I wanted, pretty disappointing.
In the meantime I installed a Virtual Machine for OS-X on my VirtualBox and installed QT on OS-X. Copied over the unchanged windows sources and compiled it with some minor changing. The DRO application was running on OS-X but the UI looked messed up with either huge fonts or very tiny 1 pixel fonts and many layout problems.
After researching using Google and building a few 1 window test application I discovered I should use CSS for every widget, layout and font. After reworking my application for a few weeks with CSS, everything worked just as designed on Windows/Linus and MAC OS-X, great, now the next OS, Android.
Android compilation was a little more challenging than Linux and OS-X as it needs Android SDK tools, Android NDK, Java SE Development Kit, Apache Ant and the Android Debug Bridge installed. After configuring QT for Android I tested it with a simple Hello World application. Hooray, it worked using the Android emulator and after fiddling also on my Note2 phone. The next step was to compile the DRO application for Android, which was done in a breeze and I fired up the app on my Note2, OMG, it did run but it needed a lot of CSS styling work and a way of handling dialogs and rotation which took at least 2 weeks.
Yes, you can develop on one platform and move it over to other platforms, but the takeaway of this adventure is to do it right from the beginning using CSS for styling, use the proper fonts available on all platforms, use QT Layouts instead of dropping all components on one form and don’t use dialogs or limit its use to an absolute minimum.
Development of the entire DRO Application was accomplished on my laptop with Windows 7 and all other OS’s using Oracle’s VirtualBox (except Android). Download the DRO applications for free from jandekkersdro.com while the Android app can be fetched from Android’s Play-Store and Amazon’s Apps and Games Store (Search for JDRO ?)
If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on LinkedIn, Twitter or Facebook. Thank you!
Jan Dekkers
Senior Software Developer at Waterdrop
8 年Have you managed to compile it for iOS too?
Software architect embedded at bbv Software Services
8 年Hi Jan I have to agree with Seyed. It would make more sense to use QML when you also target mobile devices. Also can implement a responsive UI design because it is nearly impossible to create one GUI for all devices. Regarding to the screenshots of your documentation your design seems to be developer driven and not user driven. Try to visualize the working flow and not all functions of you system. Try use the 8 golden rules of Ben Shneiderman and the 10 heuristics of UI Design by Jakob Nilson. This will improve the usability of your product a lot.
Laravel and PHP Developer
8 年thanks for sharing your experience.
CEO & Founder, UX Designer, CTO, Developer | Designing systems with awesome UX & UI in mobile, desktop, web and embedded platforms
8 年Thank you for sharing your experience. First of all, Qt is right (pronounced as 'cute') and QT (pronounced as Q.T.) is QuickTime! In my experience developing cross-platform using QML is great. I developed multiple applications for Android and iOS and MacOS. There is no need to any change for different platform. So I suggest you to migrate to QML for great features and better cross-platforming :-)