To generate a tone in Qt, we can pass our own QBuffer to the QAudioOutput to be played.
Take a look at the first example on the QAudioOutput page.
What I did was create my waveform in a QByteArray.
Remember that sin(2 * pi * frequency * i / sample_rate)
will give you a sin tone of the desired frequency:
#define FREQ_CONST ((2.0 * M_PI) / SAMPLE_RATE)
QByteArray* bytebuf = new QByteArray();
buf->resize(seconds * SAMPLE_RATE);
for (int i=0; i<(seconds * SAMPLE_RATE); i++) {
qreal t = (qreal)(freq * i);
t = t * FREQ_CONST;
t = qSin(t);
// now we normalize t
t *= TG_MAX_VAL;
(*bytebuf)[i] = (quint8)t;
}
Then we can take that buffer and do something like this to play it:
// Make a QBuffer from our QByteArray
QBuffer* input = new QBuffer(bytebuf);
input->open(QIODevice::ReadOnly);
// Create an output with our premade QAudioFormat (See example in QAudioOutput)
QAudioOutput* audio = new QAudioOutput(format, this);
audio->start(input);
If you need more example code, you can see how I did it in a little project I just started here.