Results 1 to 4 of 4

Thread: QSettings - reading from ini files with sections/groups

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Posts
    6
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QSettings - reading from ini files with sections/groups

    Hello,

    i am new to Qt and trying to build a small application right now which should save its configuration to an .ini file which is checked again on app-launch to do the initial gui filling of my app.

    Basically my ini has the following structure

    [item01]
    id=foo
    path=bar

    [item02]
    id=bla
    path=blub

    Right now i am wondering what might be the best way to read the entire file at the beginning of my application.

    My idea is to count the amount of groups / sections in the ini first.
    In the next step i could fill my UI (QListWidget) element with an QListWidget item for each group of my ini file.

    While i know that i.e.
    //
    QSettings settings( "myininame.ini", QSettings::IniFormat );
    // keys contains all elements of settings
    QStringList keys = settings.allKeys();

    works and delivers me all relevant data - its not offering any sorting-option i would like.
    Reading and writing single elements from/to the .ini works too.
    So i am unsure how to realize the loop-structure to handle each section/group on itself.
    It might help to i.e. count all sections/group at the beginning - but still not sure if i am thinking wrong here.


    I hope my main starting problem is clear- would be great if someone could push my into the right direction - right now i just dont know the amount of sections/groups which makes it difficult for me to know when to end the loop


    Best regards
    el
    Last edited by el; 18th November 2009 at 10:22.

Similar Threads

  1. Replies: 3
    Last Post: 26th July 2011, 17:59
  2. Access violation when reading big text files
    By robertson1 in forum General Programming
    Replies: 0
    Last Post: 18th September 2008, 06:59
  3. Reading files in C++
    By maverick_pol in forum General Programming
    Replies: 2
    Last Post: 15th May 2008, 08:53
  4. problem with reading text files
    By Axsis in forum Newbie
    Replies: 1
    Last Post: 25th April 2008, 12:29
  5. QWT 5, QT3, SuSE 10.2. Crash and burn
    By DrMcCleod in forum Qwt
    Replies: 8
    Last Post: 7th September 2007, 20:53

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.