C++ 你使用 Qt 吗?你为什么使用它?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/123012/
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 you use Qt and why do you use it?
提问by David Dibben
Pros. and cons? how long do you use it? What about jambi?
优点。和缺点?你用了多久?詹比呢?
采纳答案by itsmatt
I've used Qt on a couple of projects I did in c++ on several platforms over a period of seven years. I think it works pretty well and definitely was quicker for me to develop a decent GUI app on the Mac than plodding through a language I didn't know (Objective-C) at the time.
在七年的时间里,我在几个平台上用 C++ 完成的几个项目中使用了 Qt。我认为它工作得很好,而且对我来说,在 Mac 上开发一个像样的 GUI 应用程序肯定比通过我当时不知道的语言(Objective-C)缓慢前进要快。
I think the signal/slot mechanism is a bit funky but isn't horrible. Once you're use it for a bit, it's not a show stopper. The connection stuff is easy to bungle up (or at least it was) and it's always good to check the return on those because your app will go merrily on its way and not tell you that it didn't work.
我认为信号/插槽机制有点时髦,但并不可怕。一旦你使用它一段时间,它就不是一个表演障碍。连接的东西很容易搞砸(或者至少是这样),检查那些东西的回报总是好的,因为你的应用程序会愉快地前进,而不是告诉你它不起作用。
I've never used jambi.
我从来没有用过 jambi。
回答by David Dibben
I have been using Qt for several years now for commercial development and have been very happy with it.
我多年来一直在使用 Qt 进行商业开发,并且对它非常满意。
One of the nice things with Qt is that it provides a large set of libraries as well as the GUI stuff (eg XML parsing, threads, networking), all in a consistent style and all multi-platform. This means we rarely need to use other libraries, though we do use boost for some things.
Qt 的一个好处是它提供了大量的库以及 GUI 的东西(例如 XML 解析、线程、网络),所有这些都以一致的风格和所有的多平台。这意味着我们很少需要使用其他库,尽管我们确实在某些事情上使用了 boost。
Another very important factor for us was internationalization. In a previous, MFC based application we had to maintain 2 localized versions, for the two languages we support. In our Qt based app we just have the one version.
对我们来说,另一个非常重要的因素是国际化。在以前的基于 MFC 的应用程序中,我们必须为我们支持的两种语言维护 2 个本地化版本。在我们基于 Qt 的应用程序中,我们只有一个版本。
- The Qt translation system, using linguist is easy to use and makes supporting multiple languages easy (of course you still have to translate the strings which is a lot of work!)
- The GUI layout system where the widgets resize themselves according to a layout makes everything much easier. In different languages the length of the strings are different. With fixed size widgets (like MFC) each dialog needs to be adjusted for each language, otherwise parts of labels get cut off. With Qt they resize themselves. Of course, there are cases when it does not work exactly right but it still makes everything much easier.
- QString does everything in Unicode and handles the conversions from different codecs very easily.
- Qt翻译系统,使用linguist,使用方便,支持多国语言(当然你还是要翻译字符串,工作量很大!)
- 小部件根据布局调整自身大小的 GUI 布局系统使一切变得更加容易。在不同的语言中,字符串的长度是不同的。对于固定大小的小部件(如 MFC),每个对话框都需要针对每种语言进行调整,否则部分标签会被切断。使用 Qt,他们可以调整自己的大小。当然,在某些情况下它不能完全正确地工作,但它仍然使一切变得更容易。
- QString 使用 Unicode 完成所有操作,并且可以非常轻松地处理来自不同编解码器的转换。
One thing that has been very valuable is the access to the source, although e this is certainly not unique to Qt. On several occasions the ability to check the Qt source has explained some strange behaviour or given a clue how to achieve something.
非常有价值的一件事是对源代码的访问,尽管这肯定不是 Qt 独有的。有几次,检查 Qt 源代码的能力解释了一些奇怪的行为或提供了如何实现某些目标的线索。
We have found a few bugs in Qt, some of which have been fixed after reporting to Trolltech. In other cases they have suggested a work around. These have all been fairly obscure and not had a major impact on our development.
我们在 Qt 中发现了一些错误,其中一些在向 Trolltech 报告后已修复。在其他情况下,他们建议了一种解决方法。这些都相当模糊,并没有对我们的发展产生重大影响。
One of the main downsides to Qt would be the lack of 3rd party libraries for use in commercial applications. However, Qt is fairly complete so for us it has not been a big problem, though that will depend on which type of application you are developing.
Qt 的主要缺点之一是缺乏用于商业应用程序的 3rd 方库。然而,Qt 是相当完整的,所以对我们来说这不是一个大问题,尽管这取决于您正在开发的应用程序类型。
I have not used Jambi either.
我也没有用过占碑。
回答by Chris Roland
Here are some of my Pros and Cons with Qt:
以下是我使用 Qt 的一些优点和缺点:
Pros:
Cross-platform
I know this one is always used, but after going back and forth between Windows and Linux with Qt, it's amazing how little I have to do to get up and running. I think this is helped by the fact I only use Vim with Qt Designer.
QMake
This is one of my favorite aspects of Qt. After doing work in wxWidgets, FLTK, etc., I get so tired of messing around with different build systems and I don't want to manually create my makefiles. I currently use CMake on anything other than Qt right now, but I think I'm slowly moving even Qt over to CMake. However it's just so easy to get going with QMake.
QTestLib
I looked at a couple other C++ unit testing frameworks and when I created my tests using QTestLib, it felt very similar to NUnit(C#) and within minutes I had several passing tests. I also noticed that it would be very easy to create my own continuous integrationenvironment.
Closest to Java and .Net in productivity
The biggest thing I hear/read people say about C++ is, "I can be more productive with Java or .Net". From personal experience I can get a prototype of an application running in Qt using Vim and Qt Designer, before Eclipse or Visual Studio even load. I also get a very similar set of libraries in Qt that I have in .Net or Java and if it's not there I can leverage the existing C++ code out there.
Cons:
Price
This is the biggest factor I can think of right now. However, the cost is worth every cent, um if I knew how many cents I had to save up without making a call to a sales rep. I purchased a license back in the day when they had their small business discount and it was worth it then, I would've paid three times as much and I think that's the current price.
Develop anywhere with commercial license
I would love to be able to develop on any platform, but build and sell for another platform. For example, develop on Linux, then build and deploy on Windows if you just have the Windows commercial license. From what I know, you can only develop and build a commercial application on the platform you have a license for.
Vendor lock-in
Well sort of, this is more of a personal con. I don't like being tied to a specific vendor because I get side tracked by the company direction and product direction. TrollTech was purchased by Nokia, is this good or bad I don't know, but a company that size can do evil things.
I think I'm done for now :). Oh, I haven't used Jambi but I'm really interested in doing a couple prototype projects to find out how easy it is to use a plugin developed in C++ with Jambi. Especially using Jambi as a web interface with C++ plugins.
优点:
跨平台
我知道这个总是被使用,但是在使用 Qt 在 Windows 和 Linux 之间来回切换之后,令人惊讶的是我需要做的很少的事情来启动和运行。我认为这得益于我仅将 Vim 与 Qt Designer 一起使用这一事实。
QMake
这是我最喜欢的 Qt 方面之一。在 wxWidgets、FLTK 等方面工作后,我厌倦了在不同的构建系统上乱搞,我不想手动创建我的 makefile。我目前在 Qt 以外的任何东西上使用 CMake,但我认为我什至正在慢慢地将 Qt 转移到 CMake。但是,使用 QMake 非常容易。
测试库
我查看了其他几个 C++ 单元测试框架,当我使用 QTestLib 创建我的测试时,感觉它与 NUnit(C#) 非常相似,并且在几分钟内我有几个通过了测试。我还注意到创建自己的持续集成环境非常容易。
在生产力方面最接近 Java 和 .Net
我听到/读到的关于 C++ 的最重要的事情是,“我可以使用 Java 或 .Net 提高生产力”。根据个人经验,我可以在 Eclipse 或 Visual Studio 加载之前使用 Vim 和 Qt Designer 获得在 Qt 中运行的应用程序的原型。我还在 Qt 中获得了一组与 .Net 或 Java 中非常相似的库,如果没有,我可以利用现有的 C++ 代码。
缺点:
价格
这是我目前能想到的最大因素。然而,每一分钱都是值得的,嗯,如果我知道在不打电话给销售代表的情况下我必须节省多少美分。我在他们有小企业折扣的那天购买了许可证,当时很值得,我会支付三倍的费用,我认为这就是当前的价格。
使用商业许可在任何地方开发
我希望能够在任何平台上开发,但为另一个平台构建和销售。例如,如果您只有 Windows 商业许可证,则在 Linux 上开发,然后在 Windows 上构建和部署。据我所知,您只能在您拥有许可的平台上开发和构建商业应用程序。
供应商锁定
好吧,这更像是一种个人骗局。我不喜欢被绑定到特定的供应商,因为我被公司方向和产品方向所左右。TrollTech 被诺基亚收购了,我不知道这是好是坏,但这样规模的公司会做坏事。
我想我现在已经完成了:)。哦,我没有使用过 Jambi,但我真的很想做几个原型项目,以了解使用 C++ 和 Jambi 开发的插件是多么容易。特别是使用 Jambi 作为带有 C++ 插件的 Web 界面。
To be honest I haven't read much on it, so it may be impossible or very easy.
老实说,我对它的了解不多,所以这可能是不可能的或非常容易的。
回答by Rodyland
I used Qt in a previous job. I'd only had the absolute briefest of contact with Qt several years prior to that, so I was pretty much a Qt newb.
我在以前的工作中使用过 Qt。在那之前的几年里,我只与 Qt 有过最简短的接触,所以我几乎是一个 Qt 新手。
When I started I was told to choose my language and environment, but cross-platform support was desirable. I tried Qt and Java, and even gave C# a go just for the heck of it. I gave myself two days to evaluate each option.
当我开始时,我被告知选择我的语言和环境,但需要跨平台支持。我尝试了 Qt 和 Java,甚至尝试了一下 C#。我给自己两天时间来评估每个选项。
Maybe I was slightly biased with my history as a C++ developer, but after spending time on each option Qt was the only one that showed any hints at being useful without a long learning curve.
也许我对我作为 C++ 开发人员的历史略有偏见,但是在每个选项上花费了时间之后,Qt 是唯一一个在没有很长的学习曲线的情况下显示出有用的提示。
The documentation provided with Qt and the example applications made it very easy for an experienced developer but Qt beginner to get up and running very quickly. I had UI prototype/mockups of the end application done by the end of my trial period. With Java/Eclipse, Java/SunStudio and C#/VS.net I had trouble getting anything nontrivial happening in that time.
Qt 提供的文档和示例应用程序使经验丰富的开发人员和 Qt 初学者非常容易上手和运行。在试用期结束时,我已经完成了最终应用程序的 UI 原型/模型。使用 Java/Eclipse、Java/SunStudio 和 C#/VS.net 时,我很难得到任何不平凡的事情。
Signals/slots took some getting used to, but it wasn't too bad, and I wrote some simple wrappers to assert when connections failed to stop silly typos from stopping the app. from working.
信号/插槽需要一些时间来适应,但还不错,我写了一些简单的包装器来断言连接未能阻止愚蠢的错别字停止应用程序。从工作。
The other thing I liked is that Qt had almost everything I needed. You name it - storage, networking, GUI, threading, containers - Qt has a class to deal with it. Which IMHO is important because mixing libraries can sometimes cause problems.
我喜欢的另一件事是 Qt 几乎拥有我需要的一切。随便你说——存储、网络、GUI、线程、容器——Qt 有一个类来处理它。恕我直言很重要,因为混合库有时会导致问题。
Having the source code to Qt was a big plus, one for just plain interest's sake, but also it allowed me to compile Qt using the compiler and settings of my choosing, including a debug version for use during development.
拥有 Qt 的源代码是一个很大的好处,只是为了简单的兴趣,而且它允许我使用我选择的编译器和设置来编译 Qt,包括在开发过程中使用的调试版本。
I also found Trolltech's support to be fairly good. I raised a couple of bugs on Qt, one of which was fixed and released whilst I was still working on the project (only a 6 month job).
我还发现奇趣科技的支持相当不错。我在 Qt 上提出了几个错误,其中一个在我仍在从事该项目时已修复并发布(只有 6 个月的工作)。
The only negative I can recall was the difficulty in debugging Qt objects (using VS) - there is a Qt plugin for VS that can examine Qt objects but I was using the free version of VS and plugins don't work for it. But that wasn't Qt's fault.
我能记得的唯一缺点是调试 Qt 对象(使用 VS)很困难 - 有一个用于 VS 的 Qt 插件可以检查 Qt 对象,但我使用的是 VS 的免费版本,插件不适用于它。但这不是 Qt 的错。
I haven't used jambi so can't comment.
我没用过 jambi 所以无法评论。
回答by Martin Beckett
On C++ your only other alternatives are MFC and wxWidgets.
QT / wxWidgets is largely a personal preference. I do think QT is a clean design with good documentation.
QT costs about one month of developer salary if you aren't using it for GPL.
在 C++ 上,您唯一的其他选择是 MFC 和 wxWidgets。QT/wxWidgets 很大程度上是个人喜好。我确实认为 QT 是一个干净的设计和良好的文档。
如果您不将 QT 用于 GPL,则它会花费大约一个月的开发人员工资。
回答by Thomas Koschel
I have been using Qt for over two years now.
我已经使用 Qt 两年多了。
Things I like on Qt are:
我在 Qt 上喜欢的东西是:
- Easy GUI programming (compared to MFC), Qt Designer
- Nice container classes
- Nice graphics scene framework
- Excellent documentation with useful examples
- Translation support
- Good technical support
- 简单的 GUI 编程(与 MFC 相比),Qt 设计器
- 不错的容器类
- 漂亮的图形场景框架
- 带有有用示例的优秀文档
- 翻译支持
- 良好的技术支持
I can highly recommend the Qt Developer Days. If you have a chance to take part, then do it! Lots of nice and very interesting talks there.
我强烈推荐Qt 开发者日。如果你有机会参加,那就去做吧!那里有很多很好的和非常有趣的谈话。
回答by adum
Qt is a very nice library, but it has an expensive per-seat developer license, so it's not always useful for all projects.
Qt 是一个非常好的库,但它有一个昂贵的每席位开发者许可证,所以它并不总是对所有项目都有用。
回答by Greg Domjan
Don't use it, however...
但是不要使用它...
Pro: QT has an optional 3 phase layout, where as WX only allows for 2 currently (I believe they plan to do 3 phase, just have not worked it in yet).
优点:QT 有一个可选的 3 阶段布局,而 WX 目前只允许 2 阶段(我相信他们计划做 3 阶段,只是还没有使用)。
One of the bigger problems with using layouts is static text and wrapping. WX asks how big is your min width/height and portions out the screen, QT has option to say how wide do you want, how high do you need to be if your X wide. This allows you to express the flow of a page much better.
使用布局的较大问题之一是静态文本和换行。WX 询问您的最小宽度/高度和屏幕部分有多大,QT 可以选择说您想要多宽,如果您的 X 宽,您需要多高。这使您可以更好地表达页面的流程。