How to save QVector<QString> to QSettings



  • Hello I use this code to save QVector in QSettings but the program stops working

    void MainWindow::on_saveEquations_clicked()
    {
        qRegisterMetaTypeStreamOperators<QVector<QString>>("QVector<QString>");
        QSettings settingA("test","equations");
        settingA.beginGroup("MainWindowA");
        settingA.setValue("equa",QVariant::fromValue(expressions));
        settingA.endGroup();
    }
    
    void MainWindow::on_loadEquations_clicked()
    {
        QSettings settingA("test","equations");
        settingA.beginGroup("MainWindowA");
        expressions=settingA.value("equa").value<QVector<QString>>();
        settingA.endGroup();
    }
    

    QVariant::save: unable to save type 'QVector<QString>' (type id: 1032).
    solved:
    qRegisterMetaTypeStreamOperators<QVector<QString>>("QVector<QString>");
    to constructor


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.