为什么使用 QVector(Qt) 而不是 std::vector

2021-12-09 00:00:00 qt vector c++

我对 C++ 和 Qt 很陌生,但我很擅长 C#/Java.

I'm very new to C++ and Qt, but I'm very good at C#/Java.

关键是我喜欢跨平台,但我对 Qt 感到困惑.std::vector 不是已经跨平台了吗,Qt 不是提供了一个非跨平台的东西吗?

The point is I like cross-platform, but I'm confuse with Qt. Isn't std::vector already cross-platform, doesn't Qt provide an equivalent to a non-crossplatform thing?

还有 FileQFile 有什么不同?

Also how are File and QFile different?

一个链接会很好,谢谢:)

A link would be nice, thanks :)

推荐答案

这篇文章看起来不错.它比较了 Qt 模板库和标准模板库:

This article loooks good. It compares Qt Template Library with Standard Template Library:

  • QTL vs STL

希望,您会发现文章中列出的所有差异很有趣.

Hope, you'll find it interesting seeing all the differences listed there in the article.

这里是我觉得有趣的地方:

Here is what I find interesting:

我的观点是最大的QTL 的优点在于它具有相同的实现(包括二进制兼容性)在所有操作系统上Qt支持.一些 STL实现可能低于标准当谈到性能或他们可能缺少功能.一些平台甚至没有 STL!在另一方面,STL 更多可定制,可在其完整的头文件......就像我说的,没有明显的赢家.

My opinion is that the biggest advantage of the QTL is that it has the same implementation (including binary compatibility) on all OSes supported by Qt. Some STL implementations might be below par when it comes to performance or they might be missing functionality. Some platforms don’t even have an STL! On the other hand, the STL is more customizable and is available in its entirety in header files… Like I said, there is no clear winner.

就像他说的,没有明确的赢家.但是仍然阅读这篇文章会使很多事情变得清晰.了解其中的区别比不了解另一个要好.

Like he said, no clear winner. But still reading the article makes lots of things clear. Its better to know the difference than going for one, without knowing the other.

相关文章