Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Save user input
QtWS25 Last Chance

Save user input

Scheduled Pinned Locked Moved General and Desktop
10 Posts 7 Posters 5.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    FBK25
    wrote on last edited by
    #1

    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. :)

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • F Offline
        F Offline
        FBK25
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          OK, that clears it up a little.
          In that case, your code actually looks good. Using ::text() is save, there are no issues with that.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fluca1978
            wrote on last edited by
            #5

            Maybe you are looking at the wrong Competition object?

            1 Reply Last reply
            0
            • F Offline
              F Offline
              FBK25
              wrote on last edited by
              #6

              Oh man that's awkward...yes I am! :) Thank you both for your responses!

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tobias.hunger
                wrote on last edited by
                #7

                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;-).

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mansi
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    shivji
                    wrote on last edited by
                    #9

                    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

                    Pl45m4P 1 Reply Last reply
                    0
                    • S shivji

                      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

                      Pl45m4P Offline
                      Pl45m4P Offline
                      Pl45m4
                      wrote on last edited by
                      #10

                      @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.


                      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                      ~E. W. Dijkstra

                      1 Reply Last reply
                      1

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved