【发布时间】:2013-07-28 16:22:02
【问题描述】:
我正在尝试通过 QAudioInput 录制声音。根据本网站上的文档QAudioInput。但是当我运行时,它导出了一个空的原始文件。检查后,似乎函数 QTimer::singleShot 不起作用(我在 void stopRecording() 中添加了声明 qWarning << "Done" 并且它没有显示“完成”所以我认为它在 QTimer::singleShot 函数中有一些错误) .
这是我用来检查函数 QTimer::singleShot 的代码
----Check.pro----
QT += core
QT -= gui
TARGET = Check
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
HEADERS += test.h
-----test.h------
#ifndef TEST_H
#define TEST_H
#include <QCoreApplication>
#include <QTimer>
#include <iostream>
#include <QObject>
#include <test.h>
#include <QDebug>
using namespace std;
class Object: public QObject {
Q_OBJECT
private slots:
void func() { cout << "Hello"; }
};
#endif // TEST_H
----main.cpp----
#include <QCoreApplication>
#include <QTimer>
#include <iostream>
#include <QObject>
#include <test.h>
#include <QDebug>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
Object *o = new Object;
QTimer::singleShot(10000, o, SLOT(func()));
return 0;
}
而且这段代码也不起作用。谁能解释我?我是 Qt 编程的新手。
【问题讨论】: