Qt 使用qm文件-.h

时间:2024-04-23 07:24:02

#include <QtCore/QObject>
#include <QtCore/QTranslator>

class LanguageSelector:public QObeject{
    Q_OBJECT
public:
    ~LanguageSelector() override = default;
    void setLanguage(const QString &l);
    QString getLanguage();
    void addLanguageFile(const QString &n);
    void removeLanguageFile(const QString &n);
    void reload();
    static LanguageSelector *getInstance();
signals:
    void languageChanged(const QString &l);
privite:
    LanguageSelector();
    static LanguageSelector* instance;
    static constexpr char CONFIGER_KEY[] = "system/language";
    QString baseDir;
    QList<QString> languageFiles;
    QList<QTranslator *> translations;
}