诺基亚 Qt 的基本概念是什么?
诺基亚 Qt 的基本概念是什么?
在进入诺基亚 Qt 框架之前我想了解哪些事情?
有人可以帮助我吗?
我对诺基亚 Qt 还很陌生。 提前致谢。
What are the basics concepts in Nokia Qt?
What are things I want to know before entering in to Nokia Qt framework?
Could any one help me?
I'm very new for Nokia Qt.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Qt 是一个巨大的框架,具有用于处理 GUI、网络、数据库和各种事物的库。它有很好的文档记录,所以请查看如何学习诺基亚网站上的 Qt。话虽如此,以下是一些基本概念:
Qt 是一个框架。这意味着您可以围绕响应事件来组织代码。最重要的是,你没有“主循环”。您的
main
通常如下所示:信号和槽。Qt 使用信号和槽的概念以彻底解耦的方式连接程序的不同部分。您必须首先将信号连接到插槽:
然后,每当
发送方
“发出”信号时(例如,使用emit theSignal(0)
),Qt 就会安排接收方- >要调用的Slot(0)
。这种安排是通过“元对象编译器”实现的,它是一个单独的程序,可以生成您编译并链接到程序中的代码。Qt 使用信号和槽来响应 GUI 事件。因此,当您决定当用户单击“文件->打开”菜单项时程序需要执行什么操作时,您就编写了一个槽。 Qt 使用元对象编译器 (
moc
) 来预处理代码并在幕后生成大量机器,以确保该插槽可以连接到信号。在MyMainWindow
的标头中,您将看到类似以下内容:Q_OBJECT
宏对于moc
识别类并为您生成所有机制是必需的。就您的代码而言,插槽只是一个普通的方法。它可以是公共的、受保护的或私有的。就可以正常调用了。唯一的区别是您可以使用connect
将信号连接到它。信号是另一回事。
moc
为您实现所有信号,因此,继续上面的示例,MyMainWindow.cpp
将不包含mySignal
的定义。< /p>Qt 是一个非常大的框架,您可以轻松地仅使用您需要的部分。慢慢来。不要担心高级功能,或者看起来太困难的事情。弄清楚你想做什么,然后尝试去做。网上搜索。 Qt 拥有一些最广泛的文档。祝你好运!
Qt is a huge framework, with libraries for handling the GUI, network, database, and all sorts of things. It is very well documented, so go have a look at How to Learn Qt on Nokia's website. That being said, here are some of the basic concepts:
Qt is a framework. This means you organize your code around responding to events. Most importantly, you do not have a "main loop". Your
main
generally looks like this:Signals and slots. Qt uses the concepts of signals and slots to connect different parts of a program in a radically decoupled way. You must first connect a signal to a slot:
Then, when ever the
sender
"emits" the signal (using, for example,emit theSignal(0)
), then Qt arranges forreceiver->theSlot(0)
to be called. This arrangement is achieved by the "meta-object compiler", a separate program that generates code that you compile and link in to your program.Qt uses signals and slots to respond to GUI events. So when you decide what your program needs to do when the user clicks the "File->Open" menu item, you write a slot. Qt uses the meta-object compiler (
moc
) to pre-process your code and generate lots of machinery behind the scenes to make sure this slot can be connected to signals. In the header forMyMainWindow
, you will have something like:The
Q_OBJECT
macro is necessary for themoc
to recognize the class and generate all the machinery for you. As far as your code is concerned, a slot is just a normal method. It can be public, protected, or private. It can be called normally. The only difference is that you can useconnect
to connect a signal to it.Signals are a different matter. The
moc
implements all of your signals for you, so, continuing the above example,MyMainWindow.cpp
would not include a definition ofmySignal
.Qt is a very large framework, and you can easily use only the pieces you need. Go slow. Don't worry about the advanced features, or things that seem too difficult. Figure out what you want to do, then try to do that. Search online. Qt has some of the most extensive documentation out there. Good luck!
只要您了解面向对象编程,您就足以开始使用。 Qt 对 C++ 对象的主要补充是信号和槽。如果您阅读文档,它们很快就会变得有意义。
As long as you understand Object Oriented Programming, you will pretty much know enough to get started. The main addition to C++ objects from Qt is the Signals and Slots. if you read the documentation, they will start to make a lot of sense quickly.