对于 *nix 下的非 GUI 应用程序来说,什么是像样的事件库? (C++)
首先,我现在正在使用Qt。然而,我希望程序最终能够在没有 GUI 环境的情况下运行,主要将图形方面留给配置。该程序大量使用 Qt 计时器和信号/槽,部分用于 QtScript。因此,如果我想让它成为非 GUI 可操作的,希望 Qt 的某些部分可以在没有 GUI 环境的情况下运行。如果没有,也许我会研究不同的 Javascript 实现,尽管 QtScript 非常方便地集成到 Qt 和 C++ 的 OO 结构中。首先,Qt 的某些部分可以在非 GUI 环境中使用吗?如果不能,那么对于事件和调度库还有哪些其他选择?最好是OO设计。
First, I'm using Qt at the moment. However, I want the program eventually able to run without a GUI environment, leaving the graphical aspects for configuration mainly. The program makes hefty use of Qt timers and signals/slots, partially for QtScript. So if I want to make it non-GUI operable, hopefully parts of Qt can run without a GUI environment. If not, maybe I'll look into a different Javascript implementation, although QtScript is very convenient how it integrates into Qt's and C++'s OO structure. First, can parts of Qt be used in a non-GUI environment, and if not what other choices are there as far as an events and scheduling library? Preferably OO design.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
如果您不使用 QtGui 模块,则不需要 GUI。 QtCore 等都可以正常工作。
If you don't use the QtGui module, you don't need a GUI. QtCore etc. will work just fine.
你有没有看过
Boost.Signals 库? (我自己没用过。)
Have you looked at the
Boost.Signals library? (I haven't used it myself.)
libsigc++ 具有与 Qt 非常相似的信号和槽机制,尽管它是纯 C++(没有额外的预处理器)。它还可以与 GTK+ 的 C++ 绑定 gtkmm 一起使用。
也就是说,如果 Qt 要求您有 GUI,我会感到惊讶,所以您可能会坚持使用 Qt。
libsigc++ has a signals and slots mechanism very similar to Qt's though it's pure C++ (no extra pre-processor). It can also be used with gtkmm, a C++ binding for GTK+.
That said, I'd be surprised if Qt requires that you have a GUI, so you'll probably be able to stick with Qt.
libevent
可能就是你寻找。然而,这是在 C 语言中。libevent
may be what you are looking for. This is in C, however.Poco项目提供了两个有趣的解决方案:
Boost 信号 库也非常好,但它是少数需要构建和链接的 boost 库之一。
The Poco project offers two interesting solutions:
The Boost signals library is very nice too, but it's one of the few boost libraries that need to be built and linked with.