summaryrefslogtreecommitdiffstats
path: root/examples/multimediawidgets
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@qt.io>2020-06-24 12:20:29 +0200
committerJarek Kobus <jaroslaw.kobus@qt.io>2020-06-25 09:54:13 +0200
commit1818334beafcf8668b30b8ee63031f871a0c8d03 (patch)
tree6d04c661a20e392ad3c214f53cf027f95142e863 /examples/multimediawidgets
parent2c9a117e49497c55a22621d86d452fa7c22a489b (diff)
Use QList instead of QVector
Task-number: QTBUG-84469 Change-Id: Id8d07836a66e4d9223341483bfe0ed251ba2806c Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
Diffstat (limited to 'examples/multimediawidgets')
-rw-r--r--examples/multimediawidgets/player/histogramwidget.cpp22
-rw-r--r--examples/multimediawidgets/player/histogramwidget.h8
2 files changed, 15 insertions, 15 deletions
diff --git a/examples/multimediawidgets/player/histogramwidget.cpp b/examples/multimediawidgets/player/histogramwidget.cpp
index a0de8516a..bb214cad5 100644
--- a/examples/multimediawidgets/player/histogramwidget.cpp
+++ b/examples/multimediawidgets/player/histogramwidget.cpp
@@ -52,8 +52,8 @@
#include <QPainter>
#include <QHBoxLayout>
-template <class T>
-static QVector<qreal> getBufferLevels(const T *buffer, int frames, int channels);
+template<class T>
+static QList<qreal> getBufferLevels(const T *buffer, int frames, int channels);
class QAudioLevel : public QWidget
{
@@ -102,7 +102,7 @@ HistogramWidget::HistogramWidget(QWidget *parent)
: QWidget(parent)
{
m_processor.moveToThread(&m_processorThread);
- qRegisterMetaType<QVector<qreal>>("QVector<qreal>");
+ qRegisterMetaType<QList<qreal>>("QList<qreal>");
connect(&m_processor, &FrameProcessor::histogramReady, this, &HistogramWidget::setHistogram);
m_processorThread.start(QThread::LowestPriority);
setLayout(new QHBoxLayout);
@@ -163,9 +163,9 @@ qreal getPeakValue(const QAudioFormat& format)
}
// returns the audio level for each channel
-QVector<qreal> getBufferLevels(const QAudioBuffer& buffer)
+QList<qreal> getBufferLevels(const QAudioBuffer &buffer)
{
- QVector<qreal> values;
+ QList<qreal> values;
if (!buffer.isValid())
return values;
@@ -216,10 +216,10 @@ QVector<qreal> getBufferLevels(const QAudioBuffer& buffer)
return values;
}
-template <class T>
-QVector<qreal> getBufferLevels(const T *buffer, int frames, int channels)
+template<class T>
+QList<qreal> getBufferLevels(const T *buffer, int frames, int channels)
{
- QVector<qreal> max_values;
+ QList<qreal> max_values;
max_values.fill(0, channels);
for (int i = 0; i < frames; ++i) {
@@ -245,12 +245,12 @@ void HistogramWidget::processBuffer(const QAudioBuffer &buffer)
}
}
- QVector<qreal> levels = getBufferLevels(buffer);
+ QList<qreal> levels = getBufferLevels(buffer);
for (int i = 0; i < levels.count(); ++i)
m_audioLevels.at(i)->setLevel(levels.at(i));
}
-void HistogramWidget::setHistogram(const QVector<qreal> &histogram)
+void HistogramWidget::setHistogram(const QList<qreal> &histogram)
{
m_isBusy = false;
m_histogram = histogram;
@@ -284,7 +284,7 @@ void HistogramWidget::paintEvent(QPaintEvent *event)
void FrameProcessor::processFrame(QVideoFrame frame, int levels)
{
- QVector<qreal> histogram(levels);
+ QList<qreal> histogram(levels);
do {
if (!levels)
diff --git a/examples/multimediawidgets/player/histogramwidget.h b/examples/multimediawidgets/player/histogramwidget.h
index a5c697dfb..08ba4f342 100644
--- a/examples/multimediawidgets/player/histogramwidget.h
+++ b/examples/multimediawidgets/player/histogramwidget.h
@@ -66,7 +66,7 @@ public slots:
void processFrame(QVideoFrame frame, int levels);
signals:
- void histogramReady(const QVector<qreal> &histogram);
+ void histogramReady(const QList<qreal> &histogram);
};
class HistogramWidget : public QWidget
@@ -81,18 +81,18 @@ public:
public slots:
void processFrame(const QVideoFrame &frame);
void processBuffer(const QAudioBuffer &buffer);
- void setHistogram(const QVector<qreal> &histogram);
+ void setHistogram(const QList<qreal> &histogram);
protected:
void paintEvent(QPaintEvent *event) override;
private:
- QVector<qreal> m_histogram;
+ QList<qreal> m_histogram;
int m_levels = 128;
FrameProcessor m_processor;
QThread m_processorThread;
bool m_isBusy = false;
- QVector<QAudioLevel *> m_audioLevels;
+ QList<QAudioLevel *> m_audioLevels;
};
#endif // HISTOGRAMWIDGET_H