诺基亚 Qt 的基本概念是什么?

发布于 2024-10-14 20:55:02 字数 102 浏览 5 评论 0原文

诺基亚 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

反差帅 2024-10-21 20:55:02

Qt 是一个巨大的框架,具有用于处理 GUI、网络、数据库和各种事物的库。它有很好的文档记录,所以请查看如何学习诺基亚网站上的 Qt。话虽如此,以下是一些基本概念:

  1. Qt 是一个框架。这意味着您可以围绕响应事件来组织代码。最重要的是,你没有“主循环”。您的 main 通常如下所示:

    QApplication app(argc, argv);
    我的主窗口获胜;
    
    赢.show();
    
    返回app.exec();
    
  2. 信号和槽。Qt 使用信号和槽的概念以彻底解耦的方式连接程序的不同部分。您必须首先将信号连接到插槽:

    connect(发送者, SIGNAL(theSignal(int)), 接收者, SLOT(theSlot(int)));
    

    然后,每当发送方“发出”信号时(例如,使用emit theSignal(0)),Qt 就会安排接收方- >要调用的Slot(0)。这种安排是通过“元对象编译器”实现的,它是一个单独的程序,可以生成您编译并链接到程序中的代码。

    Qt 使用信号和槽来响应 GUI 事件。因此,当您决定当用户单击“文件->打开”菜单项时程序需要执行什么操作时,您就编写了一个槽。 Qt 使用元对象编译器 (moc) 来预处理代码并在幕后生成大量机器,以确保该插槽可以连接到信号。在 MyMainWindow 的标头中,您将看到类似以下内容:

    类 MyMainWindow :公共 QMainWindow
    {
         Q_OBJECT
      民众:
         我的主窗口();
      公共插槽:
         无效 on_fileOpen_activated();
      信号:
         无效 mySignal(int n);
    };
    

    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:

  1. 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:

    QApplication app(argc, argv);
    MyMainWindow win;
    
    win.show();
    
    return app.exec();
    
  2. 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:

    connect(sender, SIGNAL(theSignal(int)), receiver, SLOT(theSlot(int)));
    

    Then, when ever the sender "emits" the signal (using, for example, emit theSignal(0)), then Qt arranges for receiver->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 for MyMainWindow, you will have something like:

    class MyMainWindow : public QMainWindow
    {
         Q_OBJECT
      public:
         MyMainWindow();
      public slots:
         void on_fileOpen_activated();
      signals:
         void mySignal(int n);
    };
    

    The Q_OBJECT macro is necessary for the moc 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 use connect 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 of mySignal.

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!

一念一轮回 2024-10-21 20:55:02

只要您了解面向对象编程,您就足以开始使用。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文