Results 1 to 3 of 3

Thread: QVariant

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2017
    Posts
    3
    Thanks
    2

    Arrow QVariant

    Hello every1!

    I have this code:

    Qt Code:
    1. class Model
    2. {
    3. public:
    4. Model(const QString& path);
    5. double getVehicleWeight()
    6. {
    7. m_settings->beginGroup("vehicle");
    8. const QStringList childKeys = m_settings->childKeys();
    9. foreach (const QString &childKey, childKeys)
    10. {
    11. //Here I want to return a double using QVariant, each line of my config file have (ex: weight = 60)
    12. }
    13. m_settings->endGroup();
    14. }
    15. private:
    16. void initSettings(const QString& path);
    17. protected:
    18. std::unique_ptr<QSettings> m_settings;
    19. };
    20.  
    21. Model::Model(const QString& path)
    22. {
    23. initSettings(path);
    24. }
    25.  
    26. void Model::initSettings(const QString& path)
    27. {
    28. m_settings = std::make_unique<QSettings>(path, QSettings::IniFormat);
    29. }
    30.  
    31. int main()
    32. {
    33. Model obj("/d/users/F27279C/Desktop/TESTINI/TestINI/New folder");
    34. qDebug() << "PLS WORK!";
    35. obj.getVehicleWeight();
    36. }
    To copy to clipboard, switch view to plain text mode 
    I know the ,,foreach" will go through all my document, but i dont want that
    I want ot make a getter for every line of my config file which will return the value from it
    All the values are double
    so what I ask is:
    - how can I access a specific line of my config for ex weight or speed?
    - how can I return a double using QVariant?

    thx for help!
    Last edited by high_flyer; 25th July 2017 at 09:55.

Similar Threads

  1. QVariant::QVariant(Qt::GlobalColor)' is private
    By alenn.masic in forum Qt Programming
    Replies: 7
    Last Post: 22nd February 2013, 16:29
  2. QVariant error
    By zgulser in forum Qt Programming
    Replies: 1
    Last Post: 16th April 2012, 00:46
  3. Replies: 4
    Last Post: 4th January 2011, 12:07
  4. Replies: 1
    Last Post: 4th December 2009, 17:03
  5. QVariant question
    By yunpeng880 in forum Qt Programming
    Replies: 2
    Last Post: 5th March 2009, 00:43

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.