Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to save QVector<QString> to QSettings
Forum Updated to NodeBB v4.3 + New Features

How to save QVector<QString> to QSettings

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 1.4k Views
  • 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 Offline
    E Offline
    erytcg
    wrote on last edited by erytcg
    #1

    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
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved