Is there a widget for this?
This time I need to make a runtime edited tool.
What I mean is:I need to have a tool that has several text-boxes(vertically placed) and each of those boxes will have text,that the user can edit,hen he double clicks it.
When the text has changed,the box saves that text and shows each time the app is ran...
An example of this might be the common windows name chnage.When you double click the icon you get the ability to edit its name..:/
Something like this.Any suggestions?
Re: Is there a widget for this?
What's wrong with QLineEdit?
Re: Is there a widget for this?
But line edit won't save the text for the next app start.
Re: Is there a widget for this?
No widget will. You have to implement it yourself. Either as a QLineEdit subclass or as a QComboBox subclass. You can use QSettings for storing the data.
Re: Is there a widget for this?
What code should I write in line-edit subclass and I didn't understand how qsetting can help me with this problem.
Re: Is there a widget for this?
QSettings allow you to store some data and load it back next time the application is started. I don't know what you should write in QLineEdit subclass (I don't know if you even need to subclass QLineEdit), it depends what you want to do. Programming is something more than just taking ready components and connecting them together.
Re: Is there a widget for this?
I just need a method to make the lineedit save that text for every start up.
You tell me how to do this. :D
Re: Is there a widget for this?
Quote:
You tell me how to do this.
Read the QSettings documentation, everything is explained there (pay attention to setValue() / value() methods).
Re: Is there a widget for this?
Quote:
Originally Posted by
"BumbleBee"
I just need a method to make the lineedit save that text for every start up.
You tell me how to do this. :D
As far as I remember we've done that using QCompleter and QSettings and a bit of smart code that looked for all line edits in the form and tried to retrieve previous values for them from settings.
Re: Is there a widget for this?
Nah..completer doesn't help me with this.
And although I read the qsetting doc. I can't really understand how I attach it to the lineedit..:/
Any example code for my problem?
Thanks
Re: Is there a widget for this?
You don't attach QSettings to a line edit. I already told you, it's not always as easy as calling one method on an object passing it the other object. You need to implement everything you need on your own. I don't even know what you want to do since you said completer is not what you want.
Re: Is there a widget for this?
EDIT:- late
you dont have to attach anything. Its just a simple transfer of data (QString) to and fro (QSettings to LineEdit).
something like
settings->setValue(lineEdit.text())
lineEdit.setText(settings.value()).
Re: Is there a widget for this?
Quote:
Originally Posted by
nish
EDIT:- late
you dont have to attach anything. Its just a simple transfer of data (QString) to and fro (QSettings to LineEdit).
something like
settings->setValue(lineEdit.text())
lineEdit.setText(settings.value()).
Added you on skype.Please approve me.
Re: Is there a widget for this?
Quote:
Originally Posted by
"BumbleBee"
Added you on skype.Please approve me.
I wouldn't count on him doing that :)
Re: Is there a widget for this?
Why?
Someone help me please....
Re: Is there a widget for this?
Because you'll start bombarding him with requests to fix things for you. Currently it looks like you have totally no idea how to solve your problem. Moreover it looks like you are not willing to do any thinking yourself, you just want a ready solution.
Re: Is there a widget for this?
Oh..I have never used settings before,now I watched a YT tutorial on these..but I can't see to get how to impletment it to qlineedit.
http://www.youtube.com/watch?v=TNIkeFfzH-g
Added after 16 minutes:
Anyway did this.
Code:
void Table::loadSettings()
{
set.beginGroup("setting");
QString text
= set.
value("text").
toString();
ui->le->setText(text);
set.endGroup();
}
void Table::saveSettings()
{
set.beginGroup("setting");
set.setValue("text", ui->le->text());
set.endGroup();
}
void Table::on_load_tbn_clicked()
{
loadSettings();
}
void Table::on_save_btn_clicked()
{
saveSettings();
}
//Plus called loadSettings in constr.
Thank you all and please lock thread!
Added after 27 minutes:
Acuualy I'm not 100$% done.
This ssems tow work only once and doesn't let me to edit the text later.
However this si what I need.Among the other I need to edit text every now and then.How to?
Re: Is there a widget for this?
Come on, if you know how to store a single string, it should be easy for you to discover how to store a list of strings.
Re: Is there a widget for this?
Quote:
Originally Posted by
wysota
Come on, if you know how to store a single string, it should be easy for you to discover how to store a list of strings.
And what about the fact that it doesn't change the setting?
This seems to work only once(save the text) and doesn't let me to edit the text later.
However this is what I need.Among the others, I need to edit text every now and then.How to?
Re: Is there a widget for this?
Lay down on your bed, close your eyes, relax. Once you reach the state of emptiness in your mind, start thinking about your problem. If you didn't have any framework to help you, how would you solve the problem conceptually? After you're done thinking, write it down as a list of steps to perform and post it here.