Accessing value of lineEdit in .cpp file- [SOLVED]
-
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 -
To what line number in the above code does that point?
-
[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;
}@ -
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 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 tosnd_pcm_hw_params_set_rate_resample' wave.cpp:(.text+0x7c6): undefined reference to
snd_strerror'
wave.cpp:(.text+0x7f6): undefined reference tosnd_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.
-
Make sure you're linking the asound library, not just include its header files.
-
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.
-
[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.
-
What does your .pro file look like?
-
[quote author="mlong" date="1312296267"]What does your .pro file look like?
[/quote]@#-------------------------------------------------
Project created by QtCreator 2011-07-26T15:57:33
#-------------------------------------------------
QT += core gui
TARGET = Wave
TEMPLATE = appSOURCES += main.cpp
wave.cppHEADERS += wave.h
FORMS += wave.ui@
-
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.
-
Thanks alot, I included this line in my wave.pro and it worked:
@LIBS += -lasound@ -
Good deal! Be sure to change the title of the thread to add [Solved] if everything is working now.