[quote author="Denis Kormalev" date="1312820192"]It looks like your code freezes somewhere before w.show() and return a.exec().
Try to remove code before 92 line and see if it will help.[/quote]

Thanks for the reply. It works fine and the window pops up when I remove the code before line 92.
I put all the code back and it builds fine still but when I run it now, I get the following in my output pane and the window doesn't pop up:
@Starting /home/test/Documents/Wave-build-desktop/Wave...
Playback open error: Device or resource busy
/home/test/Documents/Wave-build-desktop/Wave exited with code 0@

[quote author="Denis Kormalev" date="1312824246"]Looks like your sound device is busy. I think you will quicker find answer on related forums, but maybe someone here will be able to help you to.[/quote]

[quote author="Denis Kormalev" date="1312824246"]Looks like your sound device is busy. I think you will quicker find answer on related forums, but maybe someone here will be able to help you to.[/quote]

Hi again Denis,
I resolved the problem with the sound device, you were right, it was busy being used somewhere else.
However, with this resolved, back to the original question :). There is still no window that pops up when I run the program. There are no error messages in the output pane this time.
Could you please help me

I tried debugging my program: I placed the line @return a.exec;@ which is the line that executes the application and pops up the window. I placed this line at different parts of the code in int main() to see what line was stopping it from popping up. The window popped up when I placed it in all parts of the code starting from the top, but it stopped at the line:
@err = transfer_methods[method].transfer_loop(handle, samples, areas);
if (err < 0)
printf("Transfer failed: %s\n", snd_strerror(err));@
This is the line of code that stops my window from popping up. I don't know why. Any help would be greatly appreciated.

[quote author="mlong" date="1312836921"]So, what exactly is happening here in your main()? Is your app supposed to play an audio sample or something before it opens the MainWindow()? (I'm assuming that the "wave" class is a QMainWindow.)
[/quote]
Yes, the wave class is a QMainWindow. Yeah, I am trying to play a sine wave and in my QmainWindow, I can input frequency and amplitude. and it will play a sine wave according to those specifications.

I also tried this: I completely removed the line which was giving me a problem, as I am executing it in under my pushButton function. So the QMainWindow pops up now, but now the window terminates as soon as I click the pushButton.

It's probably terminating because you're deleting all of your resources before you ever call a.exec(). (See lines 86-88 in your original code posting.)

If you'll pardon my candor, it looks like you've cut-and-pasted a C example from ALSA into your main() and have made a few tweaks to replace "calloc" with "new", and are just kind of expecting it to seamlessly integrate with Qt. I think that you're going to keep running into compilation and execution issues because you might not understand the nuances of the code that you're trying to use, nor the way that the event loop and everything works under Qt.

Are there more fundamental issues with C++ and/or Qt that you may need to focus on further beforehand that you might still be a little uncertain of? If there are, it may help to ask about those issues first.

This is the line of code that stops my window from popping up. I don't know why. Any help would be greatly appreciated.[/quote]

For me it sounds like this is an (perhaps endless) loop, which would mean you never get an error or a window.

[/quote]

Yes. You are right. Thank you. I removed the line from my int main() as I am calling it under my pushButton function to display the sine wave. My window pops up now but when I click the push button, my program terminates. i'm not sure why. this is my push button function:@void wave::on_pushButton_clicked()
{

This is the line of code that stops my window from popping up. I don't know why. Any help would be greatly appreciated.[/quote]

For me it sounds like this is an (perhaps endless) loop, which would mean you never get an error or a window.

[/quote]

Yes. You are right. Thank you. I removed the line from my int main() as I am calling it under my pushButton function to display the sine wave. My window pops up now but when I click the push button, my program terminates. i'm not sure why. this is my push button function:@void wave::on_pushButton_clicked()
{

actually just solved this problem, there was code in my program that was terminating it. So everything compiles without errors and runs perfectly. Just when I input values of frequency and amplitude now, it doesn't output any sine wave :( . Why does my push button function not generate a sine wave. It does generate a sine wave when I run it in terminal. Any help will be appreciated.

If you'll pardon my candor, it looks like you've cut-and-pasted a C example from ALSA into your main() and have made a few tweaks to replace "calloc" with "new", and are just kind of expecting it to seamlessly integrate with Qt. I think that you're going to keep running into compilation and execution issues because you might not understand the nuances of the code that you're trying to use, nor the way that the event loop and everything works under Qt.

Are there more fundamental issues with C++ and/or Qt that you may need to focus on further beforehand that you might still be a little uncertain of? If there are, it may help to ask about those issues first.

[/quote]

Hi mlong. I agree. Although, before I started integrating my code with Qt, I made sure that my converted code compiled with a c++ compiler in terminal i.e. g++ and ran fine to produce a sine wave. I am using Qt Creator to build a gui that lets me input frequency and amplitude and produces a sine wave with those specifications. I have now reached a stage in Qt where I have dealt with all the errors. I have no more errors, my QMainWindow pops up. Only now, the problem thhat I am having is that my pushButton function doesn't seem to be generating a sine wave.
I thank you for your help so far and I hope you will bear with me for just a little while longer. I feel like I am almost there.

[quote author="ogopa" date="1312902815"][quote author="Gerolf" date="1312900157"]# Did you check, whether line 25 is executed?

Did you try to debug it and step through to check what happens?

You have an endless loop here (where is isTrue set to false?)

If you provide a full, runnable and debuggable example, perhaps others could also try with the debugger...[/quote]

Hi, yes line 25 has executed. I just debugged it and there seems to be no issues.
isTrue is set to false under my second pushButton function (pushButton2) which is to terminate the loop. I have actually solved the issue, it doesn't terminate anymore. There are no more errors, but now, the problem is when I hit the pushButton, it doesn't generate any sine wave:( Definitely, here is my wave.cpp:
[/quote]

Hi,

As the loop executed on a button press, which means runs inside the main event loop, tzhe second button press will never be executed, as the main thread is blocked.

Regarding the other thing, I have no idea, as I have no experience in sound card programming...

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

Did you try to debug it and step through to check what happens?

You have an endless loop here (where is isTrue set to false?)

If you provide a full, runnable and debuggable example, perhaps others could also try with the debugger...[/quote]

Hi, yes line 25 has executed. I just debugged it and there seems to be no issues.
isTrue is set to false under my second pushButton function (pushButton2) which is to terminate the loop. I have actually solved the issue, it doesn't terminate anymore. There are no more errors, but now, the problem is when I hit the pushButton, it doesn't generate any sine wave:( Definitely, here is my wave.cpp:
[/quote]

Hi,

As the loop executed on a button press, which means runs inside the main event loop, tzhe second button press will never be executed, as the main thread is blocked.

Regarding the other thing, I have no idea, as I have no experience in sound card programming...