Save user input
-
Hi!
I'm a student taking a basic course in C++ programming. Currently, I'm doing a project in which a graphical user interface must be used. The teachers recommended QT for my type of application...so here I am.
Anyway, I'm using a QT GUI application and have a hard time figuring out how to save user input.
!http://i157.photobucket.com/albums/t72/FBK-25/QTpicture.jpg(Here's how it looks)!
Currently I'm using this function to save the user input, but when I display the information all I get is the information set in the default constructor.
@void addBasicCompetitionInformation::on_buttonBox_accepted()
{
this->comp1->setCompetitionName(ui->lineEdit->text().toStdString());
this->comp1->setDate(ui->lineEdit_2->text().toStdString());
this->comp1->setStartTime(ui->lineEdit_3->text().toStdString());
this->comp1->setEndTime(ui->lineEdit_4->text().toStdString());
this->comp1->setOrganizingClub(ui->lineEdit_5->text().toStdString());
this->comp1->setArena(ui->lineEdit_6->text().toStdString());
}@Have tried to google the problem, and understand that text() isn't right to use...but I'm not sure which solution is the simplest one. Does anyone have any suggestions?
If you need more code feel free to point that out. :)
-
If your whole application is based on Qt, you probably don't need the conversions back and forth the StdString. QString will do just fine, and is by many regarded as better than stdString.
It is not very clear what you want to achieve exactly. What do you mean by "saving" in this context? Saving to disk? If so, what kind of format are you looking for? There are many ways to do such a thing, but in order to recommend a good one, we have to know your targets. Also, this being homework, we'd like to ensure you learn from the excersise of course :-)
So: first step in this assignment:
clearly define your requirements. What do you need to do exactly?
what part of that requirement do you require help with?
-
The reason I need a a StdString is that practically the whole application is written in Visual Studio already. Thus, the main part of the project is implemented. Now I just need to connect what I've got to QT. :)
So, what I'm trying to accomplish in this particular case is to store the data entered in the line widgets by the user in variables belonging to a C++ class (called Competition). In order to do so I use member functions of that class (set-functions). A Competition object (comp1) is used to reach those member functions. The data (if entered) shall be stored once the user presses the "OK" button.
-
Something completely different: Are you using layouts in your UI? If not: You should:-)
I am asking since that screenshot looks like you just positioned elements on a widget (which seems how you do it in windows MFC from the little I have seen of that;-).
-
Hello,
I am kind of trying to do the same.
I have created a calendar widget and I need to store the user entered data when a button ( for instance "generate") is clicked,into a text file or xml.
How do I do it ?
I have created a button. But I am not sure as to how to go about saving user entered data into a file explicitly and where is the data stored.. how do I access it to put it in a file.
Can somebody please help me ?Thanks a lot in advance,
Mansi -
I am trying to build a conference registration application however when I use QInputDialog I am faced with no type errors and did you mean errors
My intent is to gain user input with Qinputdialog or some dialog class and display a calendar widget , the date the user selects is stored in a booking date variable
However c++ keeps crashing
Please help -
@shivji said in Save user input:
Please help
Provide more information regarding your issue (ideally in a new topic).
All you say above is that your program crashes... nobody is able to identify the problem without knowing what you are doing exactly.