Results 1 to 20 of 22

Thread: Segfault when retrieving info from QSettings

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #8
    Join Date
    Feb 2008
    Posts
    153
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    40
    Thanked 8 Times in 5 Posts

    Wink Re: Segfault when retrieving info from QSettings

    Just in case, attached is the relevant code:

    main.cpp
    Qt Code:
    1. int main(int argc, char ** argv)
    2. {
    3. ...
    4. QCoreApplication::setOrganizationName("app");
    5. QCoreApplication::setApplicationName("appmakers");
    6. QCoreApplication::setOrganizationDomain("app.com");
    7. ...
    8. return app.exec();
    9. }
    To copy to clipboard, switch view to plain text mode 


    settings.cpp
    Qt Code:
    1. #include <QtCore>
    2. #include "settings.h"
    3.  
    4. settings::settings(QWidget * parent) : QWidget(parent) {
    5. internalAppSettings = new QSettings(this);
    6. }
    7. ...
    8. QString settings::getSomeInfo() {
    9. return internalAppSettings->value("main/info", "default").toString();
    10. }
    To copy to clipboard, switch view to plain text mode 


    settings.h
    Qt Code:
    1. #ifndef SETTINGS_H
    2. #define SETTINGS_H
    3.  
    4. #include <QWidget>
    5. #include <QSettings>
    6.  
    7. class settings : public QWidget
    8. {
    9. Q_OBJECT
    10. public:
    11. settings(QWidget * parent = 0);
    12. ...
    13. QString getSomeInfo();
    14. ...
    15.  
    16. private:
    17. //Internal QSettings declaration
    18. QSettings *internalAppSettings;
    19. };
    20. #endif
    To copy to clipboard, switch view to plain text mode 

    Personally I don't see anything wrong with this... Yet I still get a segfault:

    Qt Code:
    1. Symbol this is a variable with complex or multiple locations (DWARF2), length 4.
    To copy to clipboard, switch view to plain text mode 

    This is really weird Any hints?
    Last edited by codeslicer; 18th March 2008 at 01:10. Reason: spelling error

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.