简体   繁体   English

C库的Qt包装器

[英]Qt wrapper for C libraries

I'm working on a QT project based mainly on C libraries. 我正在从事主要基于C库的QT项目。

I like the way QT works, and would like to make a C++ wrapper(with similar QT style) for each C library I'm working with. 我喜欢QT的工作方式,并且想为要使用的每个C库制作一个C ++包装器(具有类似的QT样式)。

What are your recommendations and advices. 您有什么建议和意见。 What should I do, and what I shouldn't. 我应该做什么,我不应该做什么。

I would like to hear answers based on real life experience. 我想听听基于现实生活经验的答案。

Thanks 谢谢

There is a classic article on designing Qt-style APIs which might be helpful to you. 一篇有关设计Qt样式API 的经典文章 ,可能会对您有所帮助。

In general I'd recommend following the Qt style as much as possible, and hiding the details of the underlying library where you can. 通常,我建议尽可能遵循Qt样式,并在可能的地方隐藏底层库的详细信息。 You can use the Qt source code as a reference - after all, Qt is a wrapper of C libraries to a large degree, making use of standard C, POSIX and platform-specific libraries. 您可以将Qt源代码用作参考-毕竟,Qt在很大程度上使用标准C,POSIX和特定于平台的库来包装C库。

Is there a reason not to just call the c libraries from c++? 是否有理由不只是从c ++调用c库?

I ask because this is the most major divergence of QT and GTK, QT is C++ native GTK is C native. 我问,因为这是QT和GTK的最大区别,QT是C ++原生的GTK是C原生的。 A lot of developers state they don't like GTK mostly down to the way everything has to be handled in C. 许多开发人员表示,他们不喜欢GTK主要是因为必须使用C语言处理所有事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM