QSettings :: status()在logText中返回空QString,但在QDebug()中返回字符串“0”

时间:2016-03-23 10:27:57

标签: qt

我有以下类构造函数:

UeSettings::UeSettings(QObject *parent,
                       const QString& settingsFile)
    : QObject(parent),
      m_ueSettingsFile(settingsFile)
{
    QString logText=QString();

    this->ueSetServerAddress(QString());
    this->ueSetServerPort(QString());
    this->ueSetDatabaseName(QString());
    this->ueSetDatabaseUsername(QString());
    this->ueSetDatabasePassword(QString());
    this->ueSetSettingsData(new QSettings(this->ueSettingsFile(),
                                          QSettings::IniFormat,
                                          this));

    connect(this,
            SIGNAL(ueSignalEventInfoAdded(QString)),
            parent,
            SLOT(ueSlotEventInfoAdded(QString)));

    logText=tr("[INFO]").append(" ")
                        .append(QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss:zzz"))
                        .append(" ")
                        .append(tr("Config file status ")
                        .append(this->ueSettingsData()->fileName())
                        .append(": ")
                        .append(this->ueSettingsData()->status()));

    emit this->ueSignalEventInfoAdded(logText);

    qDebug() << Q_FUNC_INFO
             << this->ueSettingsData()->status();
}   // constructor

现在,为什么我要从行QString中的QSettings::status获取空logText,为什么我会得到0(这没关系,因为这个值意味着{{ 1}})在QSettings::NoError行?

1 个答案:

答案 0 :(得分:0)

我设法用

解决了这个问题
.append(QString::number(this->ueSettingsData()->status()));

用户 Sajmplus 已提供提示。