×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    104

    QSettings working on S60v5 while not working on S60v3 fp1 and fp2

    Hello,

    I have a simple program that uses QSettings to load and store some information. I use the following code to init it:

    Code:
    	settingsFilePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
    	settings = new QSettings(settingsFilePath + "/config", QSettings::IniFormat);
    I use something like this to store settings:
    Code:
            settings->beginGroup("Application Settings");
    	if(ui.cbnumOfNewsItems->currentIndex() == 5)
    		settings->setValue("NumOfNewsItemsShown", 9999);
    	else
    		settings->setValue("NumOfNewsItemsShown", ui.cbnumOfNewsItems->currentIndex()+1);
    	settings->endGroup();
    And something like this to load settings:

    Code:
    	settings->beginGroup("Application Settings");
    	if(settings->value("NumOfNewsItemsShown").toInt() < 6)
    		ui.cbnumOfNewsItems->setCurrentIndex(settings->value("NumOfNewsItemsShown").toInt()-1);
    	else
    		ui.cbnumOfNewsItems->setCurrentIndex(5);
    	settings->endGroup();
    Now, here's my problem. Code works well in emulator on S60v5, S60v3fp1 and S60v3fp2. But when I build it for phones, it only works on S60v5. On S60v3 the settings file is created I think, because once you save something, it's saved while application is runing. But after the app is restarted it behaves as if no data was ever stored and you need to enter it again. Same story after that, data is loaded until app is restarted.

    Could someone tell me what could be causing problems?

  2. #2
    Registered User
    Join Date
    Jul 2009
    Posts
    37

    Re: QSettings working on S60v5 while not working on S60v3 fp1 and fp2

    I have a similar problem (here)
    Have you found a solution?
    Last edited by tineursic; 2011-05-15 at 10:37.

  3. #3
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: QSettings working on S60v5 while not working on S60v3 fp1 and fp2

    Folks, I am not afilated with Nokia in any way (4 years here and no Champion), because I talk openly. If you ask me, Qt is UNSUPPORTED on 4.6.3 - it will most likely never get another patch. There are GUI eekers, there are file eekers, etc.

    What I can offer, however, if my own preference keeper class which works on Maemo, Symbian and Android. The header is:
    Code:
    /*
     * ApplicationPrefs.h
     *
     *  Created on: Dec 31, 2009
     *      Author: TAMHAN
     */
    
    #ifndef APPLICATIONPREFS_H_
    #define APPLICATIONPREFS_H_
    
    #include <QtGui/QMainWindow>
     #include <QPainter>
     #include <QPixmap>
     #include <QBitmap>
    #include <QDir>
    #include <QString>
     #include <QFile>
     #include <QDateTime>
    
    #define MSG_LEN 					50
    #define NUM_OF_PLAYERS 8
    
    typedef struct{
    //Properties of 'arena'
    qint16 downspeed;
    qint16 lifeleft;
    qint16 level;
    //Next char prefs
    quint16 ticksperchar;
    qint16 tickstochar;
    //Char supply
    qint8 charsinchars;
    char supply[255];
    char charsonscreen;
    char hitstroke;
    //Statistical prefs
    quint32 startedAtTic;//tics since last start or unpause
    quint32 accumulatedTicks;//tics before paused
    quint32 servedChars;
    quint32 hitChars;
    int players;
    //Hint variables-a 0 means show again
    //The values are exactly those returned
    //from a FrmAlert call
    int charselhint;
    int mainhint;
    int stathint;
    int pausehint;
    int pausedhint;
    int unpausedhint;
    }GameConsts;
    
    typedef struct{
    //Properties of each char
    quint16 xpos[100];
    quint16 ypos[100];
    char sign[100];
    bool paused;
    
    //Game messages
    char msg1[MSG_LEN];
    quint32 msg1_framestolive;
    char msg2[MSG_LEN];
    quint32 msg2_framestolive;
    }GameVars;
    
    class ApplicationPrefs
    	{
    public:
    	ApplicationPrefs();
    	~ApplicationPrefs();
    
    public:	
    	void ApplicationPrefs::initPrefs();
    	void ApplicationPrefs::savePrefs();
    	bool playMusic;
    	TInt volume;
    	
    	quint32 easygames;
    	quint32 mediumgames;
    	quint32 hardgames;
    	quint32 secsplayed;
    	quint32 chars_served[255];
    	quint32 chars_hit[255];
    	
    	quint32 difficulty;
    	quint32 useabc;
    	quint32 useABC;
    	quint32 use123;
    	quint32 usespecial;
    public:	
    	//values for pausing
    	GameConsts *consts;
    	GameVars *vars;
    	bool paused;
    	
    private:
    	void ApplicationPrefs::defaultPrefs();
    	};
    
    #endif /* APPLICATIONPREFS_H_ */
    And the source comes next
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  4. #4
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: QSettings working on S60v5 while not working on S60v3 fp1 and fp2

    And the Source:
    Code:
    /*
     * ApplicationPrefs.cpp
     *
     *  Created on: Dec 31, 2009
     *      Author: TAMHAN
     */
    
    #include "ApplicationPrefs.h"
    
    
    ApplicationPrefs::ApplicationPrefs()
    {
    	// TODO Auto-generated constructor stub
    	consts=(GameConsts*)malloc(sizeof(GameConsts));
    	vars=(GameVars*)malloc(sizeof(GameVars));
    }
    
    ApplicationPrefs::~ApplicationPrefs()
    {
    	// TODO Auto-generated destructor stub
    	savePrefs();
    	free(consts);
    	free(vars);
    }
    
    void ApplicationPrefs::initPrefs()
    {
    	QFile prefFile(QDir::currentPath() + "/prefs.tmgn");
    	if(!prefFile.open(QIODevice::ReadOnly))
    	{
    		qDebug("FAIL");
    		defaultPrefs();
    		return;
    	}
    	QDataStream in(&prefFile);
    	quint32 version;
    	qDebug("LOAD");
    	in >> version; // not needed for this v
    	in >> ApplicationPrefs::playMusic;
    	in >> ApplicationPrefs::volume;
    	in >> ApplicationPrefs::easygames;
    	in >> ApplicationPrefs::mediumgames;
    	in >> ApplicationPrefs::hardgames;
    	in >> ApplicationPrefs::secsplayed;
    	in >> ApplicationPrefs::difficulty;
    	in >> ApplicationPrefs::useabc;
    	in >> ApplicationPrefs::useABC;
    	in >> ApplicationPrefs::use123;
    	in >> ApplicationPrefs::usespecial;
    	in.readRawData((char*)ApplicationPrefs::chars_served,sizeof(quint32)*255);
    	in.readRawData((char*)ApplicationPrefs::chars_hit,sizeof(quint32)*255);		
    	in.readRawData((char*)this->consts,sizeof(GameConsts));
    	in.readRawData((char*)this->vars,sizeof(GameVars));	
    	prefFile.close();
    }
    
    void ApplicationPrefs::savePrefs()
    {
    	QFile prefFile(QDir::currentPath() +"/prefs.tmgn");
    	qDebug("Write Go");
    		if(!prefFile.open(QIODevice::WriteOnly))
    		{
    			qDebug("Write fail!");
    			defaultPrefs();
    			return;
    		}
    		QDataStream out(&prefFile);
    		quint32 version=1;
    		out << version; // not needed for this v
    		out << ApplicationPrefs::playMusic;
    		out << ApplicationPrefs::volume;
    		out <<  ApplicationPrefs::easygames;
    		out << ApplicationPrefs::mediumgames;
    		out << ApplicationPrefs::hardgames;
    		out << ApplicationPrefs::secsplayed;
    		out << ApplicationPrefs::difficulty;
    		out << ApplicationPrefs::useabc;
    		out << ApplicationPrefs::useABC;
    		out << ApplicationPrefs::use123;
    		out << ApplicationPrefs::usespecial;
    		out.writeRawData((char*)ApplicationPrefs::chars_served,sizeof(quint32)*255);
    		out.writeRawData((char*)ApplicationPrefs::chars_hit,sizeof(quint32)*255);		
    		out.writeRawData((char*)this->consts,sizeof(GameConsts));
    		out.writeRawData((char*)this->vars,sizeof(GameVars));				
    		prefFile.close();
    }
    
    void ApplicationPrefs::defaultPrefs()
    {
    	ApplicationPrefs::playMusic=true;
    	ApplicationPrefs::volume=50;
    	ApplicationPrefs::easygames=0;
    	ApplicationPrefs::mediumgames=0;
    	ApplicationPrefs::hardgames=0;
    	ApplicationPrefs::secsplayed=0;
    	ApplicationPrefs::difficulty=0;
    	ApplicationPrefs::useabc=1;
    	ApplicationPrefs::useABC=0;
    	ApplicationPrefs::use123=0;
    	ApplicationPrefs::usespecial=0;
    }
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  5. #5
    Registered User
    Join Date
    Feb 2010
    Posts
    104

    Re: QSettings working on S60v5 while not working on S60v3 fp1 and fp2

    I have a similar problem (here)
    Have you found a solution?
    No... I found out the solution tamhanna just reposted and implemented that because I was in a hurry. It's simple and it works.
    Last edited by birch01; 2011-05-16 at 09:10. Reason: Forgot to include quote.

  6. #6
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: QSettings working on S60v5 while not working on S60v3 fp1 and fp2

    My pleasure - call it another issue fixed the QaD way
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  7. #7
    Registered User
    Join Date
    Jul 2009
    Posts
    37

    Re: QSettings working on S60v5 while not working on S60v3 fp1 and fp2

    Just for the reference, my QSettings problem was also solved.

    Next time I'll probably use tamhanna's solution.

    Thank you.

Similar Threads

  1. Record downlink while mic mute Not working on latest FP1 firmware
    By ddeveloper in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2010-04-08, 07:35
  2. Replies: 2
    Last Post: 2009-07-24, 06:04
  3. S60v3 vs S60v5
    By bll1301 in forum Symbian
    Replies: 2
    Last Post: 2009-02-26, 16:43
  4. CellID not working on s60v3
    By larshove1 in forum Mobile Web Server
    Replies: 14
    Last Post: 2007-07-12, 16:38
  5. ESmsDeliveryImmediately not working in S60v3
    By lenclud in forum Symbian
    Replies: 2
    Last Post: 2006-11-08, 09:09

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×