Make it compile against qt < 5.10 QRandomGenerator was created in qt5.10

This commit is contained in:
Laurent Montel
2020-05-19 11:19:55 +02:00
parent dc0dab6a83
commit d2531d48d3

View File

@@ -29,14 +29,20 @@
#include <QDebug>
#include <QString>
#include <QTextEdit>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
#include <QRandomGenerator>
#endif
#include <stdlib.h>
#include <time.h>
static MyWidget *newMyWidget()
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
const int randomNumber = qrand() % 100 + 1;
#else
const int randomNumber = QRandomGenerator::global()->bounded(0, 100) + 1;
#endif
if (randomNumber < 50) {
if (randomNumber < 33) {
@@ -57,6 +63,10 @@ MyMainWindow::MyMainWindow(const QString &uniqueName, KDDockWidgets::MainWindowO
, m_dockWidget9IsNonDockable(nonDockableDockWidget9)
, m_restoreIsRelative(restoreIsRelative)
{
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
qsrand(time(nullptr));
#endif
// qApp->installEventFilter(this);
auto menubar = menuBar();
auto fileMenu = new QMenu(QStringLiteral("File"));