Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved How to save QVector<QString> to QSettings

    General and Desktop
    1
    1
    1071
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      erytcg last edited by erytcg

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post