Results 1 to 20 of 22

Thread: Segfault when retrieving info from QSettings

Threaded View

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

    Default Re: Segfault when retrieving info from QSettings

    Quote Originally Posted by codeslicer View Post
    Qt Code:
    1. settings::settings(QWidget * parent) : QWidget(parent) {
    2. QSettings internalAppSettings(this);
    3. }
    To copy to clipboard, switch view to plain text mode 
    This creates a local variable called internalAppSettings that gets destroyed immediately when the constructor returns. Your member variable is left uninitialized. Try this instead:
    Qt Code:
    1. settings::settings(QWidget *parent) : QWidget(parent){
    2. internalAppSettings = new QSettings(this);
    3. }
    To copy to clipboard, switch view to plain text mode 

    Or better yet simply don't declare "internalAppSettings" as a pointer but instead as a regular object and then leave the constructor empty.

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

    codeslicer (16th 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.