在哪里和学习什么来使用Qt5?

时间:2022-05-01 19:37:13

I tried to use Qt5 but I find it very confusing.

我试着使用Qt5,但是我发现它非常混乱。

I have good knowledge of c++(I would say between intermediate-expert level) but no knowledge of javascript or QML(only basic HTML)

我有很好的c++知识(我想说是中级-专家级别),但是没有javascript或QML知识(只有基本的HTML)

When I go through the examples and tutorials provided with Qt, I find then more to be reference material or like "what's new" stuff for developers who are already using Qt. It shows me random(non systematic) parts of the vast Qt library.

当我浏览Qt提供的示例和教程时,我发现更多的是参考资料,或者是对已经在使用Qt的开发人员来说“什么是新的”。

I am currently more interested in using the Qt widget based apps rather than Qt QML based apps.

我目前更感兴趣的是使用基于Qt widget的应用,而不是基于Qt QML的应用。

So this is what I want to ask.

这就是我想问的。

  1. Is QML the main language and C++ just a supporting language? in other words, is learning QML absolutely essential to use QT?

    QML是主语言,c++仅仅是一种支持语言吗?换句话说,学习QML对于使用QT是绝对必要的吗?

  2. has using Qt for c++ based apps become a de-facto depreciated thing? Is Qt nowadays only used for QML apps?

    对于基于c++的应用程序使用Qt是否已经成为事实上贬值的事情?Qt现在只用于QML应用程序吗?

  3. What do I need to learn to be able to use Qt?

    我需要学习什么才能使用Qt?

5 个解决方案

#1


7  

I have developed a few Qt applications and to this day no knowledge whatsoever about qml. It definitely is the new way because it is newer than what you're after but if everything will be done in qml in Qt 6 or 7 I have no idea.

我已经开发了一些Qt应用程序,到目前为止我对qml一无所知。这绝对是一种新的方式,因为它比你所追求的更新,但是如果所有的事情都在qt6或7中在qml中完成,我就不知道了。

So to answer your questions:

回答你们的问题:

  1. At the moment I don't see any reason why qml would be required to develop desktop based applications using Qt. This may be different for mobile but I have no experience so far in that

    目前我看不出有什么理由要求qml使用Qt开发基于桌面的应用程序。这对移动设备来说可能会有所不同,但到目前为止我还没有这方面的经验

  2. In Qt 5 there is to my knowledge no sign of the old way becoming deprecated. Please correct me if I'm wrong

    在qt5中,据我所知,没有任何迹象表明旧的方式正在被废弃。如果我错了,请纠正我

  3. If you already have a good understand of c++ the main thing you have to learn is the principle of Signals & Slots and the main classes used in desktop applications (QApplication, QMainWindow, QWidget and QObject for instance)

    如果您已经很了解c++,那么您需要学习的主要内容是信号与插槽的原理以及桌面应用程序中使用的主要类(如QApplication、QMainWindow、QWidget和QObject)

Except that I would suggest downloading & installing Qt (including examples) and running a few of those examples. In Qt 4, there was also a program called qtdemo to which I can't find a link in Qt 5, so I don't know if it still exists. If you can get hold of if there are great examples of what you can do.

除了我建议下载和安装Qt(包括示例)并运行其中的一些示例。在qt4中,还有一个叫做qtdemo的程序,我在qt5中找不到链接,所以我不知道它是否仍然存在。如果你能找到你能做的事情的好例子。

#2


3  

  1. No. But as new features just aren't being developed for QtWidgets anymore (since 2012), you should not consider it for new development:
  2. 不。但是由于QtWidgets不再开发新的特性(从2012年开始),你不应该把它应用到新的开发中:

Yes, the Qt Widgets module we have in Qt 5 is right now marked as ‘done’, which means we don’t have anybody actively working on new features for the module at this point in time.

是的,Qt 5中的Qt Widgets模块现在被标记为“done”,这意味着我们没有任何人在这个时候为模块开发新的特性。

As someone who spent many years developing QWidget based applications, I find it vastly easier to develop UIs in QML - it's well worth learning.

作为一个花了多年时间开发基于QWidget的应用程序的人,我发现在QML中开发ui要容易得多——这很值得学习。

  1. No, and I have no idea how you have come to that conclusion. QtQuick is a front-end layer, it has very limited functionality outside of that. In other words, for all but the simplest applications, you will need a C++ (or Python, Haskell, Java, etc.) backend.

    不,我不知道你是怎么得出这个结论的。QtQuick是前端层,它的功能非常有限。换句话说,对于除了最简单的应用程序之外的所有应用程序,都需要一个c++(或Python、Haskell、Java等)后端。

  2. Qt is a (huge) framework, you can't start at the 'beginning' and learn everything until you reach the 'end' - that makes no sense. Use the tutorials to get a feel for the API design and how to approach common problems, and read the reference documentation to learn what capabilities it has.

    Qt是一个(巨大的)框架,你不能从“开始”开始学习,直到“结束”——这毫无意义。使用这些教程了解API设计以及如何处理常见问题,并阅读参考文档以了解其功能。

    As for what you need to learn: core internals, MVC, QtQuick, qmake.

    至于您需要学习的内容:核心内部组件、MVC、QtQuick、qmake。

#3


3  

There's a lot of Qt tutorial and resources available online. You can simply use a search engine to find what you want.

网上有很多Qt教程和资源。你可以使用搜索引擎找到你想要的。

The most important thing that you must learn ASAP is the concept of signal slots, for two reasons:

你必须尽快学会的最重要的东西是信号槽的概念,原因有两个:

  1. It's a fundamental concept that's used extensively in almost all classes.
  2. 这是一个基本概念,在几乎所有的类中都广泛使用。
  3. Even if you know it from other libraries (like boost.signals2), it's implemented in a different way, using connect function and the qmake preprocessor.
  4. 即使您从其他库(如boot .signals2)了解它,它也是通过一种不同的方式实现的,使用connect函数和qmake预处理器。

It's not complicated at all. You can consider it as a great help in programming, but you must learn how use it (it's easy).

一点也不复杂。您可以把它看作是编程的一个很大的帮助,但是您必须学会如何使用它(它很简单)。

QML is not essential in my opinion. It can be useful for mobile applications but, as of now, I develop desktop-only applications and I develop without problems using only C++ classes.

QML在我看来并不是必需的。它对于移动应用程序非常有用,但是,到目前为止,我只开发桌面应用程序,并且只使用c++类进行开发,没有遇到任何问题。

Qt is a very important framework that's used since years, while QML has appeared only recently. A lot of applications are built with Qt and not QML.

Qt是一个非常重要的框架,多年来一直在使用,而QML只是最近才出现。许多应用程序是用Qt而不是QML构建的。

#4


3  

Currently there are no many books about Qt5, so main source is official documentation and web, but currently available books:

目前关于Qt5的书籍不多,所以主要来源是官方文档和web,但目前有以下书籍:

  • Free book: Qt5 Cadaques, book about QML
  • 免费图书:Qt5 Cadaques,关于QML的书籍
  • General Qt book which was updated to Qt 5.3, but in russian: Qt5.3. Professionalnoe programmirovanie na C++

    通用Qt书籍,更新到Qt5.3,但是用俄语:Qt5.3。Professionalnoe programmirovanie na c++

    1. No, I know people who don't use QML at all, but someone else use it more than C++. It really depends on your needs.

      不,我知道有些人根本不使用QML,但其他人使用QML的次数比c++多。这取决于你的需要。

    2. C++ is active and for example Digia offers additional not-free modules, like Qt Charts which can be used botj with QML and C++. Also Qt developers always support new C++ standards. For example we have additional features when C++11 or C++14 was released. Hence, it is definitely not a deprecated language.

      c++是活动的,例如Digia提供了额外的非免费模块,比如Qt图表,可以与QML和c++一起使用botj。此外,Qt开发人员总是支持新的c++标准。例如,当c++ 11或c++ 14被释放时,我们有额外的特性。因此,它绝对不是一种过时的语言。

QML is just a front-end language, it is very good to build beautiful interfaces without headache, but back-end is still C++ code.

QML只是一种前端语言,很好地构建了漂亮的界面,没有什么麻烦,但是后端仍然是c++代码。

#5


2  

It's going to be hard to find complete and statistically demonstrable information about this, but I am happy to give you my opinion which is based on my 6+ years experience using Qt.

这将很难找到完整的和统计上可证明的信息,但我很高兴给你我的意见是基于我6年多的使用Qt的经验。

1) No it's not absolutely essential learning QML for using Qt, there are goals that are easier to achieve using QML and others that are easier to achieve in Qt/c++ and there are a few things that simply cannot be done with QML. For example, if you want to create a lightweight mobile cross-platform app based on simple data and where the user experience is far more important then the business logic, QML is probably the best choice. In many other cases Qt/c++ is probably a better option.

1)不,学习使用Qt的QML并不是绝对必要的,有使用QML更容易实现的目标,也有使用Qt/c++更容易实现的目标,还有一些事情是用QML根本做不到的。例如,如果您想创建一个基于简单数据的轻量级移动跨平台应用程序,并且用户体验远比业务逻辑重要,那么QML可能是最佳选择。在许多其他情况下,Qt/c++可能是更好的选择。

2) For some time c++/Qt has been the only real strong cross-platform framework for desktop application, now it's not the case anymore and also desktop applications are gradually loosing popularity, nowadays web applications and mobile applications are preferred by the large public and by managers who decide how to implement applications. In my opinion Desktop applications have become depreciated rather than Qt/c++, for those reasons Digia (the Qt owners) is pushing QML more than the traditional c++ thing, hoping managers will choose that to develop their next application rather than writing a webapp or a native mobile app.

2)在一段时间内c++ / Qt唯一真正强大的跨平台桌面应用程序框架,现在不是这样了,桌面应用程序也逐渐失去人气,如今的web应用程序和移动应用程序首选大型公共和经理决定如何实现应用程序。在我看来,桌面应用程序已经贬值了,而不是Qt/c++,正因为如此,Digia (Qt所有者)正在推动QML,而不是传统的c++程序,希望经理们选择它来开发下一个应用程序,而不是编写web应用程序或本地移动应用程序。

There is one field where Qt is still the de-facto standard and that is the embedded applications market. There are millions of devices like washing machines, cash machines, slot machines, car computers, GPS devices et cetera which are Linux-based and driven by software written totally in Qt/c++.

有一个领域Qt仍然是事实上的标准,那就是嵌入式应用程序市场。有数以百万计的设备,如洗衣机、自动取款机、*、汽车电脑、GPS设备等等,这些设备都是基于linux的,由完全用Qt/c++编写的软件驱动。

3) To start learning Qt an initial few days course would be a good idea, but it's not going to be cheap. KDAB is probably a good option, they give courses periodically both in Europe and in the US. If your budget does not allow a course then my suggestion is to look at the examples in the IDE and read (part of) the vast set of tutorials and suggestions you can find online.

3)开始学习Qt最初几天的课程是个不错的主意,但这并不便宜。KDAB可能是一个不错的选择,他们定期在欧洲和美国开设课程。如果您的预算不允许开设课程,那么我的建议是查看IDE中的示例并阅读(部分)您可以在网上找到的大量教程和建议。

#1


7  

I have developed a few Qt applications and to this day no knowledge whatsoever about qml. It definitely is the new way because it is newer than what you're after but if everything will be done in qml in Qt 6 or 7 I have no idea.

我已经开发了一些Qt应用程序,到目前为止我对qml一无所知。这绝对是一种新的方式,因为它比你所追求的更新,但是如果所有的事情都在qt6或7中在qml中完成,我就不知道了。

So to answer your questions:

回答你们的问题:

  1. At the moment I don't see any reason why qml would be required to develop desktop based applications using Qt. This may be different for mobile but I have no experience so far in that

    目前我看不出有什么理由要求qml使用Qt开发基于桌面的应用程序。这对移动设备来说可能会有所不同,但到目前为止我还没有这方面的经验

  2. In Qt 5 there is to my knowledge no sign of the old way becoming deprecated. Please correct me if I'm wrong

    在qt5中,据我所知,没有任何迹象表明旧的方式正在被废弃。如果我错了,请纠正我

  3. If you already have a good understand of c++ the main thing you have to learn is the principle of Signals & Slots and the main classes used in desktop applications (QApplication, QMainWindow, QWidget and QObject for instance)

    如果您已经很了解c++,那么您需要学习的主要内容是信号与插槽的原理以及桌面应用程序中使用的主要类(如QApplication、QMainWindow、QWidget和QObject)

Except that I would suggest downloading & installing Qt (including examples) and running a few of those examples. In Qt 4, there was also a program called qtdemo to which I can't find a link in Qt 5, so I don't know if it still exists. If you can get hold of if there are great examples of what you can do.

除了我建议下载和安装Qt(包括示例)并运行其中的一些示例。在qt4中,还有一个叫做qtdemo的程序,我在qt5中找不到链接,所以我不知道它是否仍然存在。如果你能找到你能做的事情的好例子。

#2


3  

  1. No. But as new features just aren't being developed for QtWidgets anymore (since 2012), you should not consider it for new development:
  2. 不。但是由于QtWidgets不再开发新的特性(从2012年开始),你不应该把它应用到新的开发中:

Yes, the Qt Widgets module we have in Qt 5 is right now marked as ‘done’, which means we don’t have anybody actively working on new features for the module at this point in time.

是的,Qt 5中的Qt Widgets模块现在被标记为“done”,这意味着我们没有任何人在这个时候为模块开发新的特性。

As someone who spent many years developing QWidget based applications, I find it vastly easier to develop UIs in QML - it's well worth learning.

作为一个花了多年时间开发基于QWidget的应用程序的人,我发现在QML中开发ui要容易得多——这很值得学习。

  1. No, and I have no idea how you have come to that conclusion. QtQuick is a front-end layer, it has very limited functionality outside of that. In other words, for all but the simplest applications, you will need a C++ (or Python, Haskell, Java, etc.) backend.

    不,我不知道你是怎么得出这个结论的。QtQuick是前端层,它的功能非常有限。换句话说,对于除了最简单的应用程序之外的所有应用程序,都需要一个c++(或Python、Haskell、Java等)后端。

  2. Qt is a (huge) framework, you can't start at the 'beginning' and learn everything until you reach the 'end' - that makes no sense. Use the tutorials to get a feel for the API design and how to approach common problems, and read the reference documentation to learn what capabilities it has.

    Qt是一个(巨大的)框架,你不能从“开始”开始学习,直到“结束”——这毫无意义。使用这些教程了解API设计以及如何处理常见问题,并阅读参考文档以了解其功能。

    As for what you need to learn: core internals, MVC, QtQuick, qmake.

    至于您需要学习的内容:核心内部组件、MVC、QtQuick、qmake。

#3


3  

There's a lot of Qt tutorial and resources available online. You can simply use a search engine to find what you want.

网上有很多Qt教程和资源。你可以使用搜索引擎找到你想要的。

The most important thing that you must learn ASAP is the concept of signal slots, for two reasons:

你必须尽快学会的最重要的东西是信号槽的概念,原因有两个:

  1. It's a fundamental concept that's used extensively in almost all classes.
  2. 这是一个基本概念,在几乎所有的类中都广泛使用。
  3. Even if you know it from other libraries (like boost.signals2), it's implemented in a different way, using connect function and the qmake preprocessor.
  4. 即使您从其他库(如boot .signals2)了解它,它也是通过一种不同的方式实现的,使用connect函数和qmake预处理器。

It's not complicated at all. You can consider it as a great help in programming, but you must learn how use it (it's easy).

一点也不复杂。您可以把它看作是编程的一个很大的帮助,但是您必须学会如何使用它(它很简单)。

QML is not essential in my opinion. It can be useful for mobile applications but, as of now, I develop desktop-only applications and I develop without problems using only C++ classes.

QML在我看来并不是必需的。它对于移动应用程序非常有用,但是,到目前为止,我只开发桌面应用程序,并且只使用c++类进行开发,没有遇到任何问题。

Qt is a very important framework that's used since years, while QML has appeared only recently. A lot of applications are built with Qt and not QML.

Qt是一个非常重要的框架,多年来一直在使用,而QML只是最近才出现。许多应用程序是用Qt而不是QML构建的。

#4


3  

Currently there are no many books about Qt5, so main source is official documentation and web, but currently available books:

目前关于Qt5的书籍不多,所以主要来源是官方文档和web,但目前有以下书籍:

  • Free book: Qt5 Cadaques, book about QML
  • 免费图书:Qt5 Cadaques,关于QML的书籍
  • General Qt book which was updated to Qt 5.3, but in russian: Qt5.3. Professionalnoe programmirovanie na C++

    通用Qt书籍,更新到Qt5.3,但是用俄语:Qt5.3。Professionalnoe programmirovanie na c++

    1. No, I know people who don't use QML at all, but someone else use it more than C++. It really depends on your needs.

      不,我知道有些人根本不使用QML,但其他人使用QML的次数比c++多。这取决于你的需要。

    2. C++ is active and for example Digia offers additional not-free modules, like Qt Charts which can be used botj with QML and C++. Also Qt developers always support new C++ standards. For example we have additional features when C++11 or C++14 was released. Hence, it is definitely not a deprecated language.

      c++是活动的,例如Digia提供了额外的非免费模块,比如Qt图表,可以与QML和c++一起使用botj。此外,Qt开发人员总是支持新的c++标准。例如,当c++ 11或c++ 14被释放时,我们有额外的特性。因此,它绝对不是一种过时的语言。

QML is just a front-end language, it is very good to build beautiful interfaces without headache, but back-end is still C++ code.

QML只是一种前端语言,很好地构建了漂亮的界面,没有什么麻烦,但是后端仍然是c++代码。

#5


2  

It's going to be hard to find complete and statistically demonstrable information about this, but I am happy to give you my opinion which is based on my 6+ years experience using Qt.

这将很难找到完整的和统计上可证明的信息,但我很高兴给你我的意见是基于我6年多的使用Qt的经验。

1) No it's not absolutely essential learning QML for using Qt, there are goals that are easier to achieve using QML and others that are easier to achieve in Qt/c++ and there are a few things that simply cannot be done with QML. For example, if you want to create a lightweight mobile cross-platform app based on simple data and where the user experience is far more important then the business logic, QML is probably the best choice. In many other cases Qt/c++ is probably a better option.

1)不,学习使用Qt的QML并不是绝对必要的,有使用QML更容易实现的目标,也有使用Qt/c++更容易实现的目标,还有一些事情是用QML根本做不到的。例如,如果您想创建一个基于简单数据的轻量级移动跨平台应用程序,并且用户体验远比业务逻辑重要,那么QML可能是最佳选择。在许多其他情况下,Qt/c++可能是更好的选择。

2) For some time c++/Qt has been the only real strong cross-platform framework for desktop application, now it's not the case anymore and also desktop applications are gradually loosing popularity, nowadays web applications and mobile applications are preferred by the large public and by managers who decide how to implement applications. In my opinion Desktop applications have become depreciated rather than Qt/c++, for those reasons Digia (the Qt owners) is pushing QML more than the traditional c++ thing, hoping managers will choose that to develop their next application rather than writing a webapp or a native mobile app.

2)在一段时间内c++ / Qt唯一真正强大的跨平台桌面应用程序框架,现在不是这样了,桌面应用程序也逐渐失去人气,如今的web应用程序和移动应用程序首选大型公共和经理决定如何实现应用程序。在我看来,桌面应用程序已经贬值了,而不是Qt/c++,正因为如此,Digia (Qt所有者)正在推动QML,而不是传统的c++程序,希望经理们选择它来开发下一个应用程序,而不是编写web应用程序或本地移动应用程序。

There is one field where Qt is still the de-facto standard and that is the embedded applications market. There are millions of devices like washing machines, cash machines, slot machines, car computers, GPS devices et cetera which are Linux-based and driven by software written totally in Qt/c++.

有一个领域Qt仍然是事实上的标准,那就是嵌入式应用程序市场。有数以百万计的设备,如洗衣机、自动取款机、*、汽车电脑、GPS设备等等,这些设备都是基于linux的,由完全用Qt/c++编写的软件驱动。

3) To start learning Qt an initial few days course would be a good idea, but it's not going to be cheap. KDAB is probably a good option, they give courses periodically both in Europe and in the US. If your budget does not allow a course then my suggestion is to look at the examples in the IDE and read (part of) the vast set of tutorials and suggestions you can find online.

3)开始学习Qt最初几天的课程是个不错的主意,但这并不便宜。KDAB可能是一个不错的选择,他们定期在欧洲和美国开设课程。如果您的预算不允许开设课程,那么我的建议是查看IDE中的示例并阅读(部分)您可以在网上找到的大量教程和建议。