×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    May 2011
    Posts
    48

    Smile QT - QFile - create new file

    hi
    i am new in qt and try to use this code to save a audio in file,it s nokia example but i have a problem , when i want to do this nothing happened.
    in line outputFile.setFileName("Ohter\mm\mm\mm\mm\mm\mm\mm\mm\mm\mm\test.raw"); i could not build a file or folder but when i check tst it is true,
    what is problem do you think?

    void MainWindow::startRecord()
    {
    ui->lResult->setText("Start Record");
    outputFile.setFileName("Ohter\mm\mm\mm\mm\mm\mm\mm\mm\mm\mm\test.raw");
    bool tst = outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate );

    if(tst)
    ui->lResult->setText("true");

    QAudioFormat format;
    // set up the format you want, eg.
    format.setFrequency(8000);
    format.setChannels(1);
    format.setSampleSize(8);
    format.setCodec("audio/pcm");
    format.setByteOrder(QAudioFormat::LittleEndian);
    format.setSampleType(QAudioFormat::UnSignedInt);

    QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
    if (!info.isFormatSupported(format))
    {
    format = info.nearestFormat(format);
    ui->lResult->setText("format does not compatible");
    }

    audio = new QAudioInput(format, this);
    QTimer::singleShot(3000, this, SLOT(stopRecording()));
    audio->start(&outputFile);
    ui->lResult->setText("Timer has been started!");
    }

    void MainWindow:: stopRecording()
    {
    audio->stop();
    outputFile.close();
    delete audio;
    ui->lResult->setText("Stop Record");
    }

  2. #2
    Registered User
    Join Date
    May 2011
    Posts
    48

    Re: QT - QFile - create new file

    i use win7 for develop and QT 4.7.3 RC.with 5233 Nokia!

Similar Threads

  1. Replies: 9
    Last Post: 2010-09-16, 10:19

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×