1

我正在使用 Qt Creator 4.7.1 中包含的多媒体示例。具体来说,我打开并运行没有问题的音频输入示例。

如果我创建一个新的自己的桌面项目并复制/粘贴此示例中的源代码,那么除了以下几行之外,一切似乎都正常:

qreal initialVolume = QAudio::convertVolume(m_audioInput->volume(),
                                            QAudio::LinearVolumeScale,
                                            QAudio::LogarithmicVolumeScale);

哪个抛出错误:

错误:“convertVolume”不是“QAudio”的成员</p>

这些是*.pro两个项目的文件:

audioinput built-in example

TEMPLATE = app
TARGET = audioinput

QT += multimedia widgets

HEADERS       = audioinput.h

SOURCES       = audioinput.cpp \
                main.cpp

target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/audioinput
INSTALLS += target
include(../../shared/shared.pri)

custom desktop app

#-----------------------------
#
# Project created by QtCreator
#
#-----------------------------

QT       += core gui multimedia widgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = example
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which has been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

CONFIG += c++11

SOURCES += \
        main.cpp \
        audioinput.cpp

HEADERS += \
        audioinput.h

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

会不会是*.pro文件的问题?

编辑:在控制台中执行 afind我可以找到这个包含函数的文件convertVolume

/home/user/Qt/5.11.1/Src/qtmultimedia/src/multimedia/audio/qaudio.cpp
4

0 回答 0