search

Home  >  Q&A  >  body text

c++ - qt中命令类的实现

项目是基于QT开发,项目需要对一些字符串命令进行比较,因此我打算封装一个东西,它包含我可以用到的所有字符串命令,最好是一个单独的类,我以前了解Java中可以封装一个类,包含静态对象,可以用:
类名.对象名 的方式使用
但换到qt我有些疑惑了,求教,谢谢。

PHP中文网PHP中文网2804 days ago568

reply all(1)I'll reply

  • PHPz

    PHPz2017-04-17 11:19:02

    After testing, the method is now written down:
    First, you need to create a class, which can inherit the QObject class or not. It is just a class. The creation method can be manual or you can use the menu of the development environment. I take the Command class as an example here.

    After modification:
    command.h

    #ifndef COMMAND_H
    #define COMMAND_H
    #include <QString>
    class Command
    {
    public:
        const static QString TEMP;
    };
    #endif // COMMAND_H
    

    command.cpp

    #include "command.h"
    const QString Command::TEMP="fuck the world";
    

    reply
    0
  • Cancelreply