Qt error ‘convertVolume’ is not a member of ‘QAudio’

214 Views Asked by At

I'm working with the multimedia examples included in Qt Creator 4.7.1. Specifically, I open and run without problems audioinput example.

If I create a new own desktop project and copy/paste the sources from this example, everything seems to work ok except for these lines:

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

Which throw error:

error: ‘convertVolume’ is not a member of ‘QAudio’

These are the *.pro file for both projects:

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

Could it be an issue with *.pro files?

EDIT: Executing a find in the console I can find this file which does include a function convertVolume:

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

There are 0 best solutions below