PDA

View Full Version : Is there a widget for this?



"BumbleBee"
12th October 2011, 11:00
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?

wysota
12th October 2011, 11:16
What's wrong with QLineEdit?

"BumbleBee"
12th October 2011, 11:31
But line edit won't save the text for the next app start.

wysota
12th October 2011, 11:44
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.

"BumbleBee"
12th October 2011, 11:47
What code should I write in line-edit subclass and I didn't understand how qsetting can help me with this problem.

wysota
12th October 2011, 14:04
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.

"BumbleBee"
12th October 2011, 16:21
I just need a method to make the lineedit save that text for every start up.
You tell me how to do this. :D

stampede
12th October 2011, 18:26
You tell me how to do this.
Read the QSettings documentation, everything is explained there (pay attention to setValue() / value() methods).

wysota
12th October 2011, 23:00
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.

"BumbleBee"
13th October 2011, 09:45
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

wysota
13th October 2011, 09:51
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.

nish
13th October 2011, 09:52
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()).

"BumbleBee"
13th October 2011, 10:03
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.

wysota
13th October 2011, 10:15
Added you on skype.Please approve me.

I wouldn't count on him doing that :)

"BumbleBee"
13th October 2011, 10:20
Why?
Someone help me please....

wysota
13th October 2011, 10:22
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.

"BumbleBee"
13th October 2011, 11:09
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.

void Table::loadSettings()
{
QSettings set("iWhor","whor");
set.beginGroup("setting");
QString text = set.value("text").toString();
ui->le->setText(text);
set.endGroup();
}

void Table::saveSettings()
{
QSettings set("iWhor","whor");
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?

wysota
13th October 2011, 12:11
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.

"BumbleBee"
13th October 2011, 13:29
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?

wysota
13th October 2011, 14:58
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.

"BumbleBee"
13th October 2011, 15:07
lol wut? 0_o

stampede
13th October 2011, 15:11
I think it's about time for you to solve a problem without using a ready-made code snippets. A programmer usually solves the problem first, then starts to code. I don't know why you want to do it the other way around.

wysota
13th October 2011, 15:23
He doesn't want it the other way. He wants us to think and write the code that he can later copy and paste to his program without thinking about what it does. I'm still convinced he wants QCompleter but hey, what do I know...

Michael Druckenmiller Sr
13th October 2011, 15:31
OK, Granted I am a Newbie. And, I am definately *NOT* a C++ person. So, forgive me if I didn't catch this answer.

First, there are two choices for saving "information" internally as some data type or externally in a data file.

Secondly, a decision has to be made as to what format to store the "information" in.

Internally, you could create a structure and put it in some common variable so when the dialog dies, it can be recalled when the dialog is recalled.

Externally you could use tabbed delimited, comma separated, or even a modified .INI format.

As an example lets say you have eight entry areas. You could write each entry data on a separate line in the file and as long as you read them in the same oder you write them in, you should be able to save and load to your hearts content with simple reads and writes. If you have several users you could name each "storage" file with the users name or ID.

You could also create a database. But, that is not for newbies or the faint at heart.

And, no I can't help with databases because all my experience in that area is VB-6 using DAO/ADO and you'd be using SQL.

Hope this ramble sparks some useful thoughts? (other than kill the interloper :) )

wysota
13th October 2011, 15:36
He already knows how to store data. He hasn't got the slightest idea what to do besides storing the data. That's what happens if someone's programming skills are based on tutorials.

Michael Druckenmiller Sr
13th October 2011, 15:51
I understand all too well the issue of trying to learn it all from Tutorials.

Coming from the completely alien realm of VB-6 I have found myself like a drunken sailor thrown out in Paris, France. (If you don't know the language getting an answer is impossible.)

And, when trying to complete a project with a dealine...

Well that makes things even more interesting. :)

With little or no time to actually read every page in Mark Summerfield's excellent book, "Rapid GUI Programming with Python and Qt".

It was so much easier in VB6 where to show something modal you just object.show 1

:)

You should have seen the grief I went through trying to get operator input back out of a textEdit! who would have thought that it didn;t have a .text or a getText? I didn't.

But, it was .toPlaintext!!!!

I hope that you have a great day.

And, Best wishes.

Mike Sr.
BTW: Been watching ST:Voyger on Net Flix...

"BumbleBee"
13th October 2011, 15:53
He already knows how to store data. He hasn't got the slightest idea what to do besides storing the data. That's what happens if someone's programming skills are based on tutorials.

what should they be based on?

wysota
13th October 2011, 16:09
I understand all too well the issue of trying to learn it all from Tutorials.

Coming from the completely alien realm of VB-6 I have found myself like a drunken sailor thrown out in Paris, France. (If you don't know the language getting an answer is impossible.)
But you had some programming background, that's completely different. It's ok to not know a tool you are using and learn that from tutorials but you can't learn how to be a programmer using only tutorials. It's like wanting to become a painter by watching tutorials. Sure, you'll learn to use a brush but you won't become an artist. The same rule applies here.


what should they be based on?
You can't become a programmer without knowing how to design algorithms for your problems. And there are no tutorials on that, what we can clearly see based on this thread. You followed a tutorial, ended up with exactly the same code as they did and you were unable to progress further because there was no tutorial on that. If you want to be a programmer, get a book on algorithms, or read some webpages on programming. Or do as I told you -- close your eyes and think how to solve your problem step by step without thinking about the tool you are using. If you want to build a house you don't start with looking for tutorials on how to use a hammer.

Michael Druckenmiller Sr
13th October 2011, 16:15
I hate to say this, since I am a newbie, but, some things you just can't learn the easy way. They come from pulling what few hairs are left in ones bald head out and knocking holes in cheap sheet rock with ones head.

Tutorials are a great start...

But, like me, 'we' need to actually read the book and the documentation.

Granted, I have found the documentation maddeningly obtuse and sparse when it comes helping people who are not already "in the know".

And, then you know a lot on both ends of the spectrum and have either no knowledge on something others see as "simple", or writers block!

And, for me, writing in Python, the pyQT documentation can be less enlightening than the official QT site.

For all the Experts, please realize that all of us don't know all the jargon and a *lot* of the documentation honestly doesn't make sense because of that.

For instance, how much of the documentation, say, like my question on Modality, explains what the ramifications of various settings are?

Lastly, I was castigated moving from a Windows & VB-6 background into a "real" programmers job because VB-6 isn't a programming language and Windows isn't an operating system. (If you think your code gets scrutinized???)

Now, I am the lead, on writing a major app in Python using pyQT as the GUI, and, if I say so myself, not doing too bad for a newbie.

Why, because I have a bit of imagination and creativity, without which you can't really be a programmer no matter how many tutorials you read or what language.

Anyone can write code to an explicit specification. But, going from a very vague concept to a GUI UI, and writing "acceptable" and "Useable" code, that's a programmer.

Lastly, never become so intrenched in any given block of code that you can't rewrite it and try something new.

Sorry for the rambling lecture...

Mike Sr.
It doesn't have to be "Elegant", it just has to work. You can always add "Elegance" as you skills improve...

wysota
13th October 2011, 19:49
I hate to say this, since I am a newbie, but, some things you just can't learn the easy way. They come from pulling what few hairs are left in ones bald head out and knocking holes in cheap sheet rock with ones head.

Tutorials are a great start...
Ok, but at some point you have to stop using tutorials and start thinking on your own. O.P. certainly didn't reach that point yet.


For all the Experts, please realize that all of us don't know all the jargon and a *lot* of the documentation honestly doesn't make sense because of that.
We realize that. However you can't expect us to babysit each newbie and explain everything from scratch to him. When you're on a course of say... "Using Macros in Word", they don't start teaching by explaining how to handle the mouse and they don't explain what a disk drive is. Sometimes here I have an impression that some people wake up one day and think "and today I'll become a software developer!". Then they login to their computers and immediately come here, expecting to be writing computer games in the evening. I have been learning how to program for well over 10 years after I told myself "ok, I think I'm a decent programmer now". And trust me, there were no video tutorials on everything back then.


For instance, how much of the documentation, say, like my question on Modality, explains what the ramifications of various settings are?
I'm sorry, I won't back you up here. I think the docs are pretty clear on this assuming you know what modality is. If you read the docs for Qt::WindowModality, everything is explained there.

Michael Druckenmiller Sr
13th October 2011, 20:20
I knew I needed new glasses. :)

I notice, though, that, this information is one the QTNamespace page.

I am not sure I would have made that connection without help.

And, I did do a search and came up empty. (Granted it probably wasn't phrased right.)

And, at my age (59) I am not really sure whether I did the search on Google, pyQT or the QT site!



We realize that. However you can't expect us to babysit each newbie and explain everything from scratch to him. When you're on a course of say... "Using Macros in Word", they don't start teaching by explaining how to handle the mouse and they don't explain what a disk drive is. Sometimes here I have an impression that some people wake up one day and think "and today I'll become a software developer!". Then they login to their computers and immediately come here, expecting to be writing computer games in the evening. I have been learning how to program for well over 10 years after I told myself "ok, I think I'm a decent programmer now". And trust me, there were no video tutorials on everything back then.


Point accepted and it's "well taken".

I have had the same problem as an Electronics tech dealing with Engineers! :)

wysota
13th October 2011, 20:35
I notice, though, that, this information is one the QTNamespace page.
You just need to access docs for "windowModality" and click on the hyperlink anchored to the type of the property. Anyway... getting offtopic here...

"BumbleBee"
15th October 2011, 09:44
But wysota, you didn't reply to PM.

nish
17th October 2011, 08:09
But wysota, you didn't reply to PM.
see his signature.

Please ask Qt related questions on the forum and not using private messages or visitor messages.

wysota
17th October 2011, 09:54
No no... he wasn't asking such questions :) I have already replied to his PM.

nish
17th October 2011, 10:18
i guess he asked your skype id :D

wysota
17th October 2011, 10:36
i guess he asked your skype id :D

No, he didn't :)