[SOLVED]Remember Last LineEdit data
-
You're not telling us what is "expected", so it is hard to judge where your code deviates from your plan
Just use a QSettings object on the stack (line 14 & 15)
What is makegui gogoi; doing? (line 17)
Why do you set a pointer to a QVariant in your settings? (line 20)
-
Also, you're using "Id" in line 20, and "id" in line 21.
-
[quote author="Andre" date="1363711273"]# You're not telling us what is "expected", so it is hard to judge where your code deviates from your plan
Just use a QSettings object on the stack (line 14 & 15)
What is makegui gogoi; doing? (line 17)
Why do you set a pointer to a QVariant in your settings? (line 20)[/quote]
Expected is that , when user closes and restarts the application , the QLineEdit fiels already has the previously Entered Text...makegui gogoi ; declares the object of the class makegui that is responsible for making the gui part and then calling other neseccary funtions.....
-
[quote author="mlong" date="1363711569"]Also, you're using "Id" in line 20, and "id" in line 21.
[/quote]Fixed It :)
-
You can't just "bind" a QSettings value to a widget, which I think is what you're trying to do. QSettings doesn't work that way.
You'll need to store the text from your QLineEdit by calling QSettings::setValue() each time the text changes (either as the user type it, or when you process the values -- however it's done in your gui.) This won't typically be done in main(). It is most likely best handled in your makegui class. Also, at the time you build/initialize your gui is when you'll use QSettings::value() to set your text.
-
[quote author="Andre" date="1363698916"]Of course. Make it persistant via storing it to a file, or using the QSettings class. Either way, you will need to load the information back on the next run.[/quote]
Am unable to use QSettings for this...Can u guide me with the other Way of storing in A text file and then retrieving it from there? -
Using a text file is not going to be any easier.
-
Can I get a line of code that saves text of QLineedit and on restarting the app , it is retrieved ?
Please help , its very important for my project ... -
No. The point is, that there isn't any such one line of code.
You've already been given many hints, but you refuse to take the hints given.
-
This is What was needed, its Done :)
@//read
QSettings settings("settingName");
QString aValue=settings.value("aKey").toString();//write
QSettings settings("settingName");
QString somevalue=textedit.text();
settings.setValue("aKey",somevalue);
@