Results 1 to 7 of 7

Thread: force QSettings to create .ini file in desired directory

  1. #1
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default force QSettings to create .ini file in desired directory

    Hi
    how can I force QSettings to create .ini file in desired directory.
    the following code doesnt work:

    Qt Code:
    1. QSettings _qsetsettings("ORG_NAME", "APP_NAME");
    2. ...
    3. _qsetsettings.setDefaultFormat(QSettings::IniFormat);
    4. _qsetsettings.setPath(QSettings::IniFormat,
    5. QSettings::UserScope,
    6. QDir::currentPath());
    7. _qsetsettings.sync();
    8. _qsetsettings.setDefaultFormat(QSettings::NativeFormat);
    To copy to clipboard, switch view to plain text mode 


    Regards
    navid

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: force QSettings to create .ini file in desired directory

    You can pass it a full file path and name where the file should be created.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: force QSettings to create .ini file in desired directory

    please one line of code !

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: force QSettings to create .ini file in desired directory

    Please look into the docs into the list of constructors for QSettings.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: force QSettings to create .ini file in desired directory

    all of the constructors:

    Qt Code:
    1. QSettings ( const QString & organization, const QString & application = QString(), QObject * parent = 0 )
    2. QSettings ( Scope scope, const QString & organization, const QString & application = QString(), QObject * parent = 0 )
    3. QSettings ( Format format, Scope scope, const QString & organization, const QString & application = QString(), QObject * parent = 0 )
    4. QSettings ( const QString & fileName, Format format, QObject * parent = 0 )
    5. QSettings ( QObject * parent = 0 )
    To copy to clipboard, switch view to plain text mode 

    I dont want to craete a new qsettings.
    I only want to save as .ini, the existing native format ones.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: force QSettings to create .ini file in desired directory

    I think I already told you in the other thread that you can't do that just like that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Oct 2009
    Posts
    90
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: force QSettings to create .ini file in desired directory

    with thanks to all of the posts
    it solved

    Qt Code:
    1. QString _qsname = "settings.txt";
    2. _qsname = QDir::currentPath()+"/"+_qsname;
    3. QSettings _qstini(_qsname, QSettings::IniFormat);
    4. QStringList keys = _qsetsettings.allKeys();
    5. foreach (QString qstr, keys){_qstini.setValue(qstr,_qsetsettings.value(qstr)); }
    6. _qstini.sync();
    To copy to clipboard, switch view to plain text mode 

    navid

Similar Threads

  1. some questions about install qwt
    By dycjiaoda in forum Qwt
    Replies: 1
    Last Post: 8th February 2011, 02:37
  2. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 16:21
  3. create file in another directory
    By raphaelf in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2006, 11:04

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.