Results 1 to 20 of 22

Thread: Segfault when retrieving info from QSettings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #20
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Segfault when retrieving info from QSettings

    You have null pointers and the singleton will eliminate that. Take a look at this:

    Qt Code:
    1. class Settings : public QSettings {
    2. public:
    3. Settings *instance() {
    4. static Settings *m_instance = new Settings;
    5. return m_instance;
    6. }
    7. //..
    8. protected:
    9. Settings() : QSettings(qApp){}
    10. };
    11.  
    12. void someClass::someMethod(){
    13. int v = Settings::instance()->value("param", 7).toInt();
    14. }
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to wysota for this useful post:

    codeslicer (21st March 2008)

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.