Gtk +和Qt有什么区别? [英] What are the differences between Gtk+ and Qt?

查看:524
本文介绍了Gtk +和Qt有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很多人似乎对哪个更好有意见。我并没有真正要求这些意见,我想知道的是细节:什么是使一个图形工具包与另一个不同的东西,以及Qt和Gtk +具有哪些差异?

解决方案

我不能直接对Gtk +说话,但在以前的工作中我使用了Gtkmm,在我目前的工作中我使用Qt。两者都是C ++,所以在这方面它们是一致的,但是Gtkmm只是Gtk +代码的封装,它直接是C。



当时我我记得在Ui代码中的一个主要区别是这两个工具包是如何处理布局的。有些部分我认为Gtk表现更好,有些我认为Qt表现更好。最终,你可以在任何你想要它们的地方获得你的小部件。

使用Gtkmm进行调试有点痛苦,因为这些类通常不会做任何事情,指向结构体的指针并调用Gtk +函数。这种额外的间接性可能令人讨厌。

Qt有更多的辅助代码,可以在各种设置中使用,至少与我使用的Gtkmm版本相比。当你需要为你的程序添加一个新的维度时,所有的东西都可以让线程,进程间通信和联网变得更加容易。他们也有它们的容器,如果你想要使用它们,我认为它们比STL容器有更好的界面 - 但它们最终会做同样的事情,所以这是一个很小的优势。



Gtkmm和Qt之间的信号/插槽机制不同。 Qt依靠编译过程中的额外步骤来生成元信息,它用于信号/插槽。使用信号或槽的对象必须从QObject继承,并且QObject继承必须是第一个,没有菱形结构。例如,这使得难以定义发出信号的抽象接口。另一方面,它们本质上意识到线程问题,并在必要时将信号/插槽连接转换为基于事件的连接。 Gtkmm使用SigC信号,这是直接的C ++类,对我来说似乎在更广泛的情况下很有用。另外,我记得,只有建立连接的对象需要从魔法基类继承。此外,由于插槽是对象,因此您可以将它们用作非常好的可调函数对象。



我相信还有其他的区别,但这就是我现在回顾。请记住我在Gtkmm的最后一次使用经历是在3年前,所以其中一些项目现在可能已经改变了。


A lot of people seem to have an opinion about which is better. I'm not really asking for these opinions, what I'd like to know are the details: What are the things that make one graphical toolkit different from another, and which of these differences do Qt and Gtk+ have?

解决方案

I can't speak directly to Gtk+, but at my previous job I used Gtkmm, and at my current job I use Qt. Both are C++, so in that regard they are consistent, but Gtkmm is/was only a wrapper to the Gtk+ code, which is in straight C.

At the time I switched jobs, I recall that one of the main differences in the Ui code was how the two toolkits handled layouts. Some parts I thought Gtk did better, some I thought Qt did better. Both let you get your widgets where you want them, eventually.

Debugging with Gtkmm was a bit of a pain, because the classes generally didn't do anything except hold a pointer to a struct and call Gtk+ functions. That extra level of indirection could be annoying.

Qt has more ancillary code that can be useful in various settings, at least compared to the version of Gtkmm that I was using. Things to make threading, inter-process communication, and networking easier are all appreciated when you need to add a new dimension to your program. They also have their containers, if you want to use those, which I think have a saner interface than the STL containers -- but they do about the same thing in the end, so it's a slight advantage.

The signal/slot mechanism between Gtkmm and Qt is different. Qt relies on an extra step in the compile process to generate meta information, which it uses for its signal/slots. An object using signals or slots must inherit from a QObject, and the QObject inheritance must be the first one, with no diamond structure. This makes it difficult to define an abstract interface that emits a signal, for example. On the plus side, they are inherently aware of threading issues, and will convert the signal/slot connection into an event-based connection when necessary. Gtkmm uses SigC signals, which are straightforward C++ classes, and to me appear to be useful in a wider variety of situations. Also, only objects that make a connection need to inherit from the magic base class, as I recall. Plus, since the slots are objects, you can use them as very nice adaptable functor objects as well.

I'm sure there are other differences, but that is what I recall now. Bear in mind my last experience with Gtkmm was about 3 years ago, so some of those items may have changed by now.

这篇关于Gtk +和Qt有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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