diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 4404053..466bcc1 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -60,18 +60,20 @@ #include #include #include -#include +#include +#include +#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) +#include +#endif + #ifdef Q_OS_WIN #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include #endif #endif -#include -#include - #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