27

I’m about to port one of my Mac applications to Windows. The Mac app uses Apple’s native Cocoa/Appkit frameworks for the UI. The UI is Obj-C code, and the core app functionality is portable C++ code.

Now I’m looking for a way to port the app to Windows and to make it look and feel native to Windows users. My choices are Microsoft’s MFC and the Qt framework. Though I’m sure MFC apps have the native look and feel, what I remember from MFC coding the framework itself is horrible. I took a look into Qt and like it from the developer’s perspective.

But as I am not a Windows user I have no idea whether Qt apps have a native Windows look and feel.

Thus my question: Can I make (without a lot of work) a Qt app behave and look like it was written with the native Windows frameworks?

TRiG
  • 10,148
  • 7
  • 57
  • 107

5 Answers5

26

You can easily change the style of a Qt application. On Windows and Mac the default style is actually using the native functions for drawing windows, controls and the like.

Additionally Qt does take many measures so that even the smallest aspects of an application (things you wouldn't even think of) emulate the native behaviour of a specific platform. So your Qt application can also replace your current Mac application when ported.

I extremely advise you not to use MFC, you will regret it (especially if you never worked with the native Win32 API). It's the complete opposite of Qt regarding flexibility and ease of use.

Christian Rau
  • 45,360
  • 10
  • 108
  • 185
  • 6
    If you check Qt's source, you'll see that these statements are misleading. Qt reimplements the Windows look&feel. If it called native GUI functions, these styles would not work on Linux, for example. More accurately, it uses native raster graphics functions. – user1095108 Sep 02 '13 at 06:35
  • 2
    @user1095108 I think you're thinking about the "Windows 95" theme of Qt? That one is indeed an emulation. But the native themes actually *don't* work on Linux or anywhere else other than Windows. – Nikos C. Sep 02 '13 at 07:17
  • I meant the `QWindowsStyle` which is the base of `QWindowsXPStyle` and `QWindowsVistaStyle`, didn't know it was '95. How can say "theme"? It is a style. – user1095108 Sep 02 '13 at 08:33
  • 6
    Hi, for example, in Mac, in apps designed using Objective C+Cocoa/Swift, the scrollbars exhibit the bounce effect, that it, if you hit the top or bottom of the scroll area with a high 'velocity', you will see the scrollbar and the area bouncing back upto some distance before settling back. Qt apps on Mac don't exhibit this behavior.. – SexyBeast Sep 18 '15 at 19:09
  • +1 for advising to stay away from MFC. Unless you really have to because your program is already written in MFC for example. – hetepeperfan Oct 30 '15 at 12:08
  • user1095108 is right. Qt paints its own widgets. https://stackoverflow.com/questions/24584189/how-does-qt-draw-its-gui-components-basic-idea But there has been some progress to include native controls. https://www.qt.io/blog/2017/02/06/native-look-feel – Kevin Muhuri Sep 07 '20 at 21:08
12

As you can read on doc.qt.io:

Qt Widgets are traditional user interface elements that are typically found in desktop environments. The widgets integrate well to the underlying platform providing native look'n'feel on Windows, Linux and Mac OSX.

Take a look at Qt Widget Gallery:

Qt's support for widget styles and themes enables your application to fit in with the native desktop enviroment.

You might be interested in a presentation called How to Make Your Qt Application Look Native:

Qt uses native style APIs on each supported platform, however there are some additional tricks you can use to make sure your Qt-based application looks, feels and behaves better. This presentation will run through examples, tips and ticks to help you make your applications look great on all platforms.

Bill
  • 11,595
  • 6
  • 44
  • 52
5

No they do NOT. It's close, but the controls look non-native. What people mean is that it uses the Win32 API for rendering the controls similar to how Windows renders the native controls so the performance should be comparible.

Only Windows specific frameworks like .NET Windows Forms use the actual native Win32 controls for common UI elements.

Monstieur
  • 7,992
  • 10
  • 51
  • 77
5

They look a bit and they don't feel a lot.

Especially if you design the app with windows in mind (like you do with cocoa). I have not yet seen ribbons (there is a commercial 3rd party clone) and the MFC blue/black style or a list view in grouped icon view.

Unfortunately WxWidgets is also very ugly to program. Better then MFC for sure. There are only two options left if you want a real native looking app, MFC (if you need fast and small) or .NET (if you don't care about speed).

A previous company had a 50000 LOC layer on top of MFC which was necessary to be able to program this 1992 framework a bit more comfortable). Unfortunately i do not know of anything available on the market that does the same.

The question is do your customers really appreciate a native look that it becomes a sales factor or not. I'm now using QT because it is good enough.

Lothar
  • 12,537
  • 6
  • 72
  • 121
3

You should have a look at the Style reference. Yes it's possible, and no it doesn't require a lot of work (at all).

cgmb
  • 4,284
  • 3
  • 33
  • 60
Mat
  • 202,337
  • 40
  • 393
  • 406