How to resolve error messages related to QtChart, QtMultimedia, and QAudioDeviceInfo?
-
I have an old project named MotherVoice, which was written in Qt 5.14.0 several years ago. In preparation for upgrading to Qt 6, I downloaded Qt 5.15.2 and Qt Creator 14.0.1 and updated my scripts accordingly. The updated project is now working properly in Qt 5.15.2. I also checked and confirmed that I had not used any deprecated functions in my scripts.
Following the "porting-to-Qt6" instructions posted on the Qt webpage (https://doc.qt.io/qt-6/portingguide.html), I proceeded to install Qt 6.8.0 on my computer. However, when I built this project, I encountered 121 error messages. That is a lot of error messages. The good news is that many of these error messages are very similar to each other. It seems that most of the error messages are related to the QtChart and QtMultimedia modules, as well as the QAudioDeviceInfo.
For example, here is an error message related to QtChart.
Here is an error message related to QtChart::QLineSeries
It appears that the QtChart module no longer exists in Qt 6, which is causing a series of error messages.
For clarity, here are some portions of my scripts where pointers of several QtChart objects were initialized.
#include <QtCharts> #include <QtCharts/QLineSeries> #include <QtCharts/QValueAxis> #include <QtCharts/QChart> #include <QtCharts/QChartView> // initialize pointers for QtChart objects QtCharts::QLineSeries *lineSeries1 = nullptr; QtCharts::QLineSeries *lineSeries3 = nullptr; QtCharts::QLineSeries *lineSeries5 = nullptr; QtCharts::QValueAxis *axisX1 = nullptr; QtCharts::QValueAxis *axisY1 = nullptr; QtCharts::QValueAxis *axisX3 = nullptr; QtCharts::QValueAxis *axisY3 = nullptr; QtCharts::QValueAxis *axisX5 = nullptr; QtCharts::QValueAxis *axisY5 = nullptr; QtCharts::QChart *chart1 = nullptr; QtCharts::QChart *chart3 = nullptr; QtCharts::QChart *chart5 = nullptr; QtCharts::QChartView *chartView1 = nullptr; QtCharts::QChartView *chartView3 = nullptr; QtCharts::QChartView *chartView5 = nullptr;
Here is an error message related to QtMultimedia::QAudioFormat.
It appears that the QtMultimedia module no longer exists in Qt 6, which is causing another series of error messages.
For clarity, here are some portions of my scripts where 'QtMultimedia' objects were initialized:
#include <QtMultimedia/qaudioformat.h> #include <QtMultimedia/qaudiooutput.h> // initialize pointers for QAudioFormat and QAudioOutput objects QAudioFormat audioFormat; QAudioOutput *audio = nullptr; // create and setup a QAudioFormat object audioFormat.setSampleRate(static_cast<int>(DATA.fs)); audioFormat.setChannelCount(1); audioFormat.setSampleSize(32); audioFormat.setCodec("audio/pcm"); audioFormat.setByteOrder(QAudioFormat::Endian(QSysInfo::ByteOrder)); audioFormat.setSampleType(QAudioFormat::Float); // create an audio output with QAudioFormat audio = new QAudioOutput(audioFormat, this);
Here is an error message related to QAudioDeviceInfo.
For clarity, here is a portion of my scripts that is related to this error message:
// create a QAudioDeviceInfo object, to make sure that our audioFormat is supported by the device QAudioDeviceInfo deviceInfo(QAudioDeviceInfo::defaultOutputDevice()); if(!deviceInfo.isFormatSupported(audioFormat)) { qWarning() << "Raw audio format not supported by backend, cannot play audio."; return; }
I tried to follow the instructions posted on the Qt's "porting-to-Qt6" webpage; however, I was unable to resolve these error messages. I also watched several YouTube videos, but I was still unable to resolve them.
I am just a self-taught hobbyist in Qt programming, so I apologize for any gaps in my knowledge on these matters.
Any comments or suggestions would be greatly appreciated!
-
After considerable effort, I finally updated the QtMultimedia portions of my scripts to Qt 6, with no error messages during the build process. It also worked properly at runtime. Hooray! That is quite an accomplishment.
Thank you all for your help!
-
No, the modules are still available, but you need to check the boxes while installing Qt6.
You can add the modules by running the maintenance tool again.
But the QtMultimedia classes do have changed a lot. ForQAudioDeviceInfo
there're new classes namedQMediaDevices
andQAudioDevice
which have similar functions
I'm not sure if there's any guide to port these classes, I just read the examples provided by Qt6 and also look for possible function names in the assistant.
I guess you should check theAudio Devices Example
.
(I do not use QtCharts so don't know it has changed or not) -
Thanks a lot for your prompt and insightful responses. Greatly appreciated!
I did include Qt Charts and Qt Multimedia when installing Qt6. Thank you for pointing this out. Thank you also for describing the other changes. They are useful information. In the meantime, I will try those new changes and continue searching for possible solutions to resolve these error messages.
-
Wrt to QtCharts you should take a look here: https://doc.qt.io/qt-6/qtcharts-changes-qt6.html
There is also such a page for every other module. -
@Christian-Ehrlicher
Yes! I followed the instructions over the Qt webpage and resolved all error messages related to QtCharts. Thank you SO MUCH!I will be working on the other error messages.
-
Yes! Following your comments, I replaced QAudioDeviceInfo with QMediaDevices and QAudioDevice with success. Thank you SO MUCH!
I will be working on the QtMultimedia classes the next.
-
This post is deleted!
-
After considerable effort, I finally updated the QtMultimedia portions of my scripts to Qt 6, with no error messages during the build process. It also worked properly at runtime. Hooray! That is quite an accomplishment.
Thank you all for your help!
-