Qt 应用程序在 Windows 下看起来和感觉是原生的吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7298441/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Do Qt apps look and feel native under Windows?
提问by Christian Rau
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.
我即将将我的 Mac 应用程序之一移植到 Windows。Mac 应用程序的 UI 使用 Apple 的原生 Cocoa/Appkit 框架。UI 是 Obj-C 代码,核心应用程序功能是可移植的 C++ 代码。
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.
现在我正在寻找一种将应用程序移植到 Windows 并使其外观和感觉对 Windows 用户来说是本机的方法。我的选择是微软的 MFC 和 Qt 框架。虽然我确信 MFC 应用程序具有原生的外观和感觉,但我记得 MFC 对框架本身进行编码时的内容很糟糕。我从开发人员的角度研究了 Qt 并喜欢它。
But as I am not a Windows user I have no idea whether Qt apps have a native Windows look and feel.
但由于我不是 Windows 用户,我不知道 Qt 应用程序是否具有原生的 Windows 外观和感觉。
Thus my question: Can I make (without a lotof work) a Qt app behave and look like it was written with the native Windows frameworks?
因此,我的问题是:我可以(无需大量工作)使 Qt 应用程序的行为和外观看起来像是使用本机 Windows 框架编写的吗?
回答by Christian Rau
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.
您可以轻松更改 Qt 应用程序的样式。在 Windows 和 Mac 上,默认样式实际上是使用本机功能来绘制窗口、控件等。
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.
此外,Qt 确实采取了许多措施,因此即使是应用程序的最小方面(您甚至不会想到的事情)也能模拟特定平台的本机行为。因此,您的 Qt 应用程序在移植时也可以替换您当前的 Mac 应用程序。
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.
我强烈建议你不要使用 MFC,你会后悔的(特别是如果你从来没有使用过原生的 Win32 API)。在灵活性和易用性方面,它与 Qt 完全相反。
回答by Bill
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.
Qt Widgets 是传统的用户界面元素,通常出现在桌面环境中。这些小部件很好地集成到底层平台,在 Windows、Linux 和 Mac OSX 上提供原生的外观。
Take a look at Qt Widget Gallery:
看看Qt 小部件库:
Qt's support for widget styles and themes enables your application to fit in with the native desktop enviroment.
Qt 对小部件样式和主题的支持使您的应用程序能够适应本机桌面环境。
You might be interested in a presentation called How to Make Your Qt Application Look Native:
您可能对名为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.
Qt 在每个受支持的平台上都使用本机风格的 API,但是您可以使用一些额外的技巧来确保基于 Qt 的应用程序的外观、感觉和行为更好。本演示文稿将贯穿示例、提示和标记,以帮助您使您的应用程序在所有平台上看起来都很棒。
回答by Lothar
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.
特别是如果您在设计应用程序时考虑到了 Windows(就像使用可可一样)。我还没有看到丝带(有一个商业 3rd 方克隆)和 MFC 蓝/黑样式或分组图标视图中的列表视图。
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).
不幸的是,WxWidgets 也很难编程。肯定比 MFC 好。如果您想要一个真正具有原生外观的应用程序,只剩下两个选项,MFC(如果您需要快速和小型)或 .NET(如果您不关心速度)。
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.
以前的一家公司在 MFC 之上有一个 50000 LOC 层,这对于能够更舒适地对这个 1992 框架进行编程是必要的)。不幸的是,我不知道市场上有什么可以做同样的事情。
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.
问题是您的客户是否真的喜欢原生外观,它是否会成为销售因素。我现在正在使用 QT,因为它已经足够好了。
回答by Monstieur
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.
不,他们没有。它很接近,但控件看起来不是本地的。人们的意思是,它使用 Win32 API 来呈现控件,类似于 Windows 呈现本机控件的方式,因此性能应该是可比的。
Only Windows specific frameworks like .NET Windows Forms use the actual native Win32 controls for common UI elements.
只有像 .NET Windows 窗体这样的 Windows 特定框架才使用实际的本地 Win32 控件来处理常见的 UI 元素。
回答by Mat
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).
您应该查看样式参考。是的,这是可能的,不,它不需要很多工作(根本不需要)。