Qt错误“ convertVolume”不是“ QAudio”的成员

时间:2018-10-04 11:58:27

标签: qt qaudioinput

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

如果我创建一个新的桌面项目并复制/粘贴此示例中的源代码,则除了以下几行外,其他一切似乎都可以正常工作

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

哪个抛出错误:

  

错误:“ convertVolume”不是“ QAudio”的成员

这是两个项目的*.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文件是否有问题?

编辑:在控制台中执行find时,我发现此文件确实包含函数convertVolume

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

0 个答案:

没有答案