Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Accessing value of lineEdit in .cpp file- [SOLVED]
Forum Updated to NodeBB v4.3 + New Features

Accessing value of lineEdit in .cpp file- [SOLVED]

Scheduled Pinned Locked Moved Qt Creator and other tools
23 Posts 4 Posters 18.3k Views 1 Watching
  • 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.
  • EddyE Offline
    EddyE Offline
    Eddy
    wrote on last edited by
    #10

    Have you changed the value of the lineedit to 5 for instance? Then normally you should get
    bq. teststring : 5
    in the application output.

    What do you have in the application output pane?

    Qt Certified Specialist
    www.edalsolutions.be

    1 Reply Last reply
    0
    • O Offline
      O Offline
      ogopa
      wrote on last edited by
      #11

      I don't have an output because when I build or run, it gives me the error:
      ./Dialog/dialog.cpp:41:11: error: ‘ui’ was not declared in this scope

      1 Reply Last reply
      0
      • EddyE Offline
        EddyE Offline
        Eddy
        wrote on last edited by
        #12

        To what line number in the above code does that point?

        Qt Certified Specialist
        www.edalsolutions.be

        1 Reply Last reply
        0
        • O Offline
          O Offline
          ogopa
          wrote on last edited by
          #13

          [quote author="Eddy" date="1311969905"]To what line number in the above code does that point?[/quote]

          line 37:
          @static int write_loop(QString)
          {
          txt = ui->lineEdit->text().toDouble();......................line 37
          cout<<"I have"<<txt;
          }@

          1 Reply Last reply
          0
          • EddyE Offline
            EddyE Offline
            Eddy
            wrote on last edited by
            #14

            Do you know how to use Qt Creator? Do you know how to debug? Please read the Qt Creator manual if you don't. The purpose of this forum is not that we debug for you. You should be able to narrow down the problems yourself.

            So your problem is merely about the static variable. Why do you want to use static? Using the signal slots you can have the value of the lineEdit where you want all the times.

            If you keep only the function with the qDebug line in it then your program should work and you have a solution to your initial problem : using the vale of lineEdit in a function.
            Hint : comment the others out and start from there.

            Qt Certified Specialist
            www.edalsolutions.be

            1 Reply Last reply
            0
            • O Offline
              O Offline
              ogopa
              wrote on last edited by
              #15

              [quote author="Eddy" date="1311971610"]Do you know how to use Qt Creator? Do you know how to debug? Please read the Qt Creator manual if you don't. The purpose of this forum is not that we debug for you. You should be able to narrow down the problems yourself.

              So your problem is merely about the static variable. Why do you want to use static? Using the signal slots you can have the value of the lineEdit where you want all the times.

              If you keep only the function with the qDebug line in it then your program should work and you have a solution to your initial problem : using the vale of lineEdit in a function.
              Hint : comment the others out and start from there.[/quote]

              Yayy, I got it, Thanks alot. I now have new errors. All of them are similar:
              wave.cpp:(.text+0x7b3): undefined reference to snd_pcm_hw_params_set_rate_resample' wave.cpp:(.text+0x7c6): undefined reference to snd_strerror'
              wave.cpp:(.text+0x7f6): undefined reference to snd_pcm_hw_params_set_access' wave.cpp:(.text+0x809): undefined reference to snd_strerror'
              wave.cpp:(.text+0x83c): undefined reference to `snd_pcm_hw_params_set_format'

              its the same for all others from the alsa sound library. I have included alsa/asoundlib.h, so i'm confused as to why i am getting these errors. Could you please help me.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mlong
                wrote on last edited by
                #16

                Make sure you're linking the asound library, not just include its header files.

                Software Engineer
                My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                1 Reply Last reply
                0
                • EddyE Offline
                  EddyE Offline
                  Eddy
                  wrote on last edited by
                  #17

                  bq. Yayy, I got it, Thanks alot. I now have new errors. All of them are similar:

                  Glad you made it that far!

                  You described your new problem much better. Now it's easier for the forum members to understand your problem and help out.

                  Qt Certified Specialist
                  www.edalsolutions.be

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    ogopa
                    wrote on last edited by
                    #18

                    [quote author="mlong" date="1311975549"]Make sure you're linking the asound library, not just include its header files.
                    [/quote]

                    Hi, I tried searching online for your suggestion as I am not sure how to do this, but I couldn't find anything that could help me. Would you please explain a little more? I'd really appreciate it.

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      mlong
                      wrote on last edited by
                      #19

                      What does your .pro file look like?

                      Software Engineer
                      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                      1 Reply Last reply
                      0
                      • O Offline
                        O Offline
                        ogopa
                        wrote on last edited by
                        #20

                        [quote author="mlong" date="1312296267"]What does your .pro file look like?
                        [/quote]

                        wave.pro

                        @#-------------------------------------------------

                        Project created by QtCreator 2011-07-26T15:57:33

                        #-------------------------------------------------

                        QT += core gui

                        TARGET = Wave
                        TEMPLATE = app

                        SOURCES += main.cpp
                        wave.cpp

                        HEADERS += wave.h

                        FORMS += wave.ui@

                        1 Reply Last reply
                        0
                        • M Offline
                          M Offline
                          mlong
                          wrote on last edited by
                          #21

                          It's not enough to simply include the <alsa/asoundlib.h> header in your code. You also have to tell the linker that you want to use the asound library. Use the LIBS variable in your .pro file to do so. I don't know for sure what the proper library name to use is (off the top of my head.) Probably want to use -Lasound or something like that.

                          There are a number of threads that discuss how to include libraries.

                          Software Engineer
                          My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                          1 Reply Last reply
                          0
                          • O Offline
                            O Offline
                            ogopa
                            wrote on last edited by
                            #22

                            Thanks alot, I included this line in my wave.pro and it worked:
                            @LIBS += -lasound@

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              mlong
                              wrote on last edited by
                              #23

                              Good deal! Be sure to change the title of the thread to add [Solved] if everything is working now.

                              Software Engineer
                              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

                              1 Reply Last reply
                              0

                              • Login

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