Results 1 to 9 of 9

Thread: QList, duplicate problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Qt products
    Qt5
    Platforms
    MacOS X
    Thanks
    13
    Thanked 153 Times in 150 Posts

    Default Re: QList, duplicate problem

    Quote Originally Posted by MichaU1337 View Post
    Qt Code:
    1. QSettings settings("MichaU", "BeingFit");
    2. QStringList ProfileList;
    3. LoadProfileList();
    To copy to clipboard, switch view to plain text mode 

    SaveProfile() Function:
    Qt Code:
    1. QSettings settings("MichaU", "BeingFit");
    2. ProfileList.append(ui->CreateProfile->text()); //my lineEdit
    3. settings.setValue("ProfileList", ProfileList);
    4. qDebug() << "Settings Saved:" << ProfileList;
    To copy to clipboard, switch view to plain text mode 

    LoadProfile() Function:
    Qt Code:
    1. QSettings settings("MichaU", "BeingFit");
    2. settings.value("ProfileList").toStringList();
    3. qDebug() << "Settings Loaded:" << settings.value("ProfileList").toStringList();
    To copy to clipboard, switch view to plain text mode 

    It should be working, I dont know why it clears the list every time. Any Ideas?
    You need an lvalue on your statement that reads the QStringList from the settings file in the LoadProfile() function or else the QStringList is read from the settings file and immediately discarded because you haven't assigned the results to anything. Try this:
    Qt Code:
    1. ProfileList = settings.value("ProfileList").toStringList();
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2014
    Location
    Cracow
    Posts
    6
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QList, duplicate problem

    Allright, we are home! Thanks for the help!

Similar Threads

  1. removing duplicate itens from QList<int>
    By john_god in forum Qt Programming
    Replies: 6
    Last Post: 7th August 2014, 06:56
  2. Problem with QSqlQuery and duplicate entry
    By Pit in forum Qt Programming
    Replies: 5
    Last Post: 27th August 2012, 11:40
  3. Replies: 4
    Last Post: 20th August 2010, 13:54
  4. Replies: 1
    Last Post: 16th June 2010, 20:19

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.