Qt:Qt类与标准C ++ [英] Qt: Qt classes vs. standard C++

查看:205
本文介绍了Qt:Qt类与标准C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大量功能在标准c ++和Qt之间重复。在某些时候看起来很合理,但很多时候它看起来很愚蠢。就像我想做一个新的编程语言,学习我已经知道的东西。例如使用QFile。

A large amount of functionality is duplicated between standard c++ and Qt. At some point it seems logical but many times it looks foolish. Like I feel like doing a new programming language, learning things which I already know. e.g. using QFile.

此外,如果我做所有的Qt方式,并假设现在我想移出Qt框架,将是太冗长乏味重写该代码。 OTOH我喜欢Qt,因为它为我提供了图书馆,否则我不得不自己像webkit,数据库连接,dbus等。

Also if I do it all Qt way and suppose now I want to move out of Qt framework it will be too much tedious to rewrite that code. OTOH I like Qt because it provides me with libraries which otherwise I would have to fish myself like webkit, database connectivity, dbus etc.

你建议混合标准C ++或做纯净的Qt方式?

What do you suggest mix standard C++ or do it pure Qt way?

推荐答案

由于没有GUI在C ++中你应该抽象的GUI代码从其余的真实代码。

As there is no GUI in C++ you should abstract the GUI code from the rest of the real code.

然后在您的GUI抽象的QT实现中,可以随意使用QT代码。

然后,您将能够编写Wx / Quartz GUI的抽象,而不影响真正的代码。

Then within your QT implementation of your GUI abstraction feel free to use QT code.
You will also then be able to write Wx/Quartz GUI abstraction without affecting the real code.

在真正的代码(工作完成)坚持标准的东西(或跨平台libs几乎标准))。可以说QT是跨平台的。只要记住,使用lib在这里将紧密耦合你的代码lib,因此提取它后面的日期将是不平凡的。 (请参阅上一个有关从旧版应用程序中删除Rouge Wave的问题)

In the real code (were the work is done) stick to standard stuff (or cross platform libs that are nearly standard (boost)). One could argue that QT is cross platform. Just remember that that using a lib here will be tightly coupling your code the lib, thus extracting it latter date will be non trivial. (see the previous question about removing Rouge Wave from a legacy application)

这篇关于Qt:Qt类与标准C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆