Removed QRandomNumberGenerator for Qt versions < 5.10

This commit is contained in:
Uwe Kindler 2022-11-15 14:35:52 +01:00
parent 260a2ddb24
commit ac1a0962d3

View File

@ -60,18 +60,20 @@
#include <QToolButton>
#include <QToolBar>
#include <QPointer>
#include <QRandomGenerator>
#include <QMap>
#include <QElapsedTimer>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#ifdef Q_OS_WIN
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QAxWidget>
#endif
#endif
#include <QMap>
#include <QElapsedTimer>
#include "DockManager.h"
#include "DockWidget.h"
#include "DockAreaWidget.h"
@ -84,6 +86,21 @@
#include "ImageViewer.h"
/**
* Returns a random number from 0 to highest - 1
*/
int randomNumberBounded(int highest)
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
return QRandomGenerator::global()->bounded(highest);
#else
qsrand(QTime::currentTime().msec());
return qrand() % highest;
#endif
}
/**
* Function returns a features string with closable (c), movable (m) and floatable (f)
* features. i.e. The following string is for a not closable but movable and floatable
@ -328,7 +345,7 @@ struct MainWindowPrivate
{
static int ImageViewerCount = 0;
auto w = new CImageViewer();
auto ImageIndex = QRandomGenerator::global()->bounded(4);
auto ImageIndex = randomNumberBounded(4);
auto FileName = ":adsdemo/images/ads_logo.svg";
// Pick a random image from a number of images