Results 1 to 2 of 2

Thread: QSettings error

  1. #1
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows Symbian S60

    Default QSettings error

    Hi! This is my first time to program in Qt and having problems with QSettings. I followed a code i saw online

    Qt Code:
    1. private:
    2. QSettings settings;
    To copy to clipboard, switch view to plain text mode 

    and adding this to the constructor:
    Qt Code:
    1. MainWindow::MainWindow(QWidget *parent) :
    2. ...
    3. settings("Contemposoft", "SimpleTextEdit")
    To copy to clipboard, switch view to plain text mode 

    but i get the folowing error:

    no match for call to '(QSettings) (const char [5], const char [8])'

    thanks

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSettings error

    That error message does not match the code lines you posted (it implies you used strings of 5 and 8 characters).

    The error arises because you have put the attempt to initialize "settings" inside the constructor (where it is already default constructed) rather than in the constructor initialization list (where you have the opportunity to dictate how to construct it).

    Qt Code:
    1. class MainWindow: public QMainWindow {
    2. Q_OBJECT
    3. public:
    4. MainWindow(QWidget *p = 0): QMainWindow(p),
    5. settings("Contemposoft", "SimpleTextEdit")
    6. {
    7. // up there ^^^^ , not in here
    8. }
    9. ...
    10. private:
    11. QSettings settings;
    12. };
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Replies: 1
    Last Post: 14th January 2011, 11:57
  2. how to use Qsettings
    By elDua in forum Newbie
    Replies: 1
    Last Post: 5th August 2010, 21:22
  3. Value from QSettings
    By wirasto in forum Newbie
    Replies: 7
    Last Post: 14th January 2010, 18:52
  4. QSettings.
    By afflictedd2 in forum Qt Programming
    Replies: 1
    Last Post: 5th April 2009, 19:14
  5. Migrate Qt3 QSettings to Qt4 QSettings
    By hvengel in forum Qt Programming
    Replies: 3
    Last Post: 22nd February 2008, 03:21

Tags for this Thread

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.