diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp index 822791533b0..420fd6186ac 100644 --- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp +++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp @@ -56,29 +56,28 @@ #include //! [0] -const double DefaultCenterX = -0.637011f; -const double DefaultCenterY = -0.0395159f; -const double DefaultScale = 0.00403897f; +const double DefaultCenterX = -0.637011; +const double DefaultCenterY = -0.0395159; +const double DefaultScale = 0.00403897; -const double ZoomInFactor = 0.8f; +const double ZoomInFactor = 0.8; const double ZoomOutFactor = 1 / ZoomInFactor; const int ScrollStep = 20; //! [0] //! [1] -MandelbrotWidget::MandelbrotWidget(QWidget *parent) - : QWidget(parent) +MandelbrotWidget::MandelbrotWidget(QWidget *parent) : + QWidget(parent), + centerX(DefaultCenterX), + centerY(DefaultCenterY), + pixmapScale(DefaultScale), + curScale(DefaultScale) { - centerX = DefaultCenterX; - centerY = DefaultCenterY; - pixmapScale = DefaultScale; - curScale = DefaultScale; - connect(&thread, &RenderThread::renderedImage, this, &MandelbrotWidget::updatePixmap); setWindowTitle(tr("Mandelbrot")); -#ifndef QT_NO_CURSOR +#if QT_CONFIG(cursor) setCursor(Qt::CrossCursor); #endif resize(550, 400); @@ -102,7 +101,7 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */) //! [4] //! [5] - if (curScale == pixmapScale) { + if (qFuzzyCompare(curScale, pixmapScale)) { //! [5] //! [6] painter.drawPixmap(pixmapOffset, pixmap); //! [6] //! [7] @@ -176,8 +175,8 @@ void MandelbrotWidget::keyPressEvent(QKeyEvent *event) //! [12] void MandelbrotWidget::wheelEvent(QWheelEvent *event) { - int numDegrees = event->angleDelta().y() / 8; - double numSteps = numDegrees / 15.0f; + const int numDegrees = event->angleDelta().y() / 8; + const double numSteps = numDegrees / double(15); zoom(pow(ZoomInFactor, numSteps)); } //! [12] diff --git a/examples/corelib/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp index eee44c7242b..22ce81c32d0 100644 --- a/examples/corelib/threads/mandelbrot/renderthread.cpp +++ b/examples/corelib/threads/mandelbrot/renderthread.cpp @@ -57,9 +57,6 @@ RenderThread::RenderThread(QObject *parent) : QThread(parent) { - restart = false; - abort = false; - for (int i = 0; i < ColormapSize; ++i) colormap[i] = rgbFromWaveLength(380.0 + (i * 400.0 / ColormapSize)); } @@ -102,10 +99,10 @@ void RenderThread::run() { forever { mutex.lock(); - QSize resultSize = this->resultSize; - double scaleFactor = this->scaleFactor; - double centerX = this->centerX; - double centerY = this->centerY; + const QSize resultSize = this->resultSize; + const double scaleFactor = this->scaleFactor; + const double centerX = this->centerX; + const double centerY = this->centerY; mutex.unlock(); //! [3] @@ -128,20 +125,20 @@ void RenderThread::run() if (abort) return; - uint *scanLine = + auto scanLine = reinterpret_cast(image.scanLine(y + halfHeight)); - double ay = centerY + (y * scaleFactor); + const double ay = centerY + (y * scaleFactor); for (int x = -halfWidth; x < halfWidth; ++x) { - double ax = centerX + (x * scaleFactor); + const double ax = centerX + (x * scaleFactor); double a1 = ax; double b1 = ay; int numIterations = 0; do { ++numIterations; - double a2 = (a1 * a1) - (b1 * b1) + ax; - double b2 = (2 * a1 * b1) + ay; + const double a2 = (a1 * a1) - (b1 * b1) + ax; + const double b2 = (2 * a1 * b1) + ay; if ((a2 * a2) + (b2 * b2) > Limit) break; @@ -187,9 +184,9 @@ void RenderThread::run() //! [10] uint RenderThread::rgbFromWaveLength(double wave) { - double r = 0.0; - double g = 0.0; - double b = 0.0; + double r = 0; + double g = 0; + double b = 0; if (wave >= 380.0 && wave <= 440.0) { r = -1.0 * (wave - 440.0) / (440.0 - 380.0); diff --git a/examples/corelib/threads/mandelbrot/renderthread.h b/examples/corelib/threads/mandelbrot/renderthread.h index 4f0394d554a..934cc17d741 100644 --- a/examples/corelib/threads/mandelbrot/renderthread.h +++ b/examples/corelib/threads/mandelbrot/renderthread.h @@ -78,7 +78,7 @@ protected: void run() override; private: - uint rgbFromWaveLength(double wave); + static uint rgbFromWaveLength(double wave); QMutex mutex; QWaitCondition condition; @@ -86,8 +86,8 @@ private: double centerY; double scaleFactor; QSize resultSize; - bool restart; - bool abort; + bool restart = false; + bool abort = false; enum { ColormapSize = 512 }; uint colormap[ColormapSize]; diff --git a/examples/opengl/paintedwindow/paintedwindow.cpp b/examples/opengl/paintedwindow/paintedwindow.cpp index 799431a765e..94aa2152881 100644 --- a/examples/opengl/paintedwindow/paintedwindow.cpp +++ b/examples/opengl/paintedwindow/paintedwindow.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include #include diff --git a/examples/opengl/qopenglwindow/main.cpp b/examples/opengl/qopenglwindow/main.cpp index 8932269ddfa..7ce4dd0977f 100644 --- a/examples/opengl/qopenglwindow/main.cpp +++ b/examples/opengl/qopenglwindow/main.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include diff --git a/examples/qpa/qrasterwindow/main.cpp b/examples/qpa/qrasterwindow/main.cpp index 958da2205af..699c950c27b 100644 --- a/examples/qpa/qrasterwindow/main.cpp +++ b/examples/qpa/qrasterwindow/main.cpp @@ -50,6 +50,7 @@ #include #include +#include #include #include #include diff --git a/examples/sql/doc/src/drilldown.qdoc b/examples/sql/doc/src/drilldown.qdoc index 8beb515a839..a7a9601c26d 100644 --- a/examples/sql/doc/src/drilldown.qdoc +++ b/examples/sql/doc/src/drilldown.qdoc @@ -437,6 +437,9 @@ \snippet drilldown/imageitem.h 0 + We declare a \c Type enum value for our custom item and reimplement + \l{QGreaphicsItem::}{type()}. This is done so we can safely use + qgraphicsitem_cast(). In addition, we implement a public \c id() function to be able to identify the associated location and a public \c adjust() function that can be called to ensure that the image item is given the diff --git a/examples/sql/drilldown/imageitem.h b/examples/sql/drilldown/imageitem.h index abb9103c7eb..324c847b122 100644 --- a/examples/sql/drilldown/imageitem.h +++ b/examples/sql/drilldown/imageitem.h @@ -60,8 +60,11 @@ class ImageItem : public QObject, public QGraphicsPixmapItem Q_OBJECT public: + enum { Type = UserType + 1 }; + ImageItem(int id, const QPixmap &pixmap, QGraphicsItem *parent = nullptr); + int type() const override { return Type; } void adjust(); int id() const; diff --git a/examples/widgets/painting/basicdrawing/renderarea.cpp b/examples/widgets/painting/basicdrawing/renderarea.cpp index a1437dea8f8..09d610ee95a 100644 --- a/examples/widgets/painting/basicdrawing/renderarea.cpp +++ b/examples/widgets/painting/basicdrawing/renderarea.cpp @@ -51,6 +51,7 @@ #include "renderarea.h" #include +#include //! [0] RenderArea::RenderArea(QWidget *parent) diff --git a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp index 31150cd994e..34a63e0eea1 100644 --- a/examples/widgets/widgets/styles/norwegianwoodstyle.cpp +++ b/examples/widgets/widgets/styles/norwegianwoodstyle.cpp @@ -52,6 +52,7 @@ #include #include +#include #include #include diff --git a/mkspecs/android-clang/qmake.conf b/mkspecs/android-clang/qmake.conf index 31ee5d26371..5cc5a20f717 100644 --- a/mkspecs/android-clang/qmake.conf +++ b/mkspecs/android-clang/qmake.conf @@ -43,6 +43,9 @@ isEmpty(ALL_ANDROID_ABIS): ALL_ANDROID_ABIS = arm64-v8a armeabi-v7a x86_64 x86 CONFIG += $$ANDROID_PLATFORM +ANDROID_MIN_SDK_VERSION = $$replace(ANDROID_PLATFORM, "android-", "") +ANDROID_TARGET_SDK_VERSION = 28 + NDK_LLVM_PATH = $$NDK_ROOT/toolchains/llvm/prebuilt/$$NDK_HOST QMAKE_CC = $$NDK_LLVM_PATH/bin/clang QMAKE_CXX = $$NDK_LLVM_PATH/bin/clang++ diff --git a/mkspecs/features/android/android_deployment_settings.prf b/mkspecs/features/android/android_deployment_settings.prf index f375a687a95..7cda5096b1f 100644 --- a/mkspecs/features/android/android_deployment_settings.prf +++ b/mkspecs/features/android/android_deployment_settings.prf @@ -53,6 +53,12 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-embedded { !isEmpty(ANDROID_VERSION_CODE): \ FILE_CONTENT += " \"android-version-code\": $$emitString($$ANDROID_VERSION_CODE)," + !isEmpty(ANDROID_MIN_SDK_VERSION): \ + FILE_CONTENT += " \"android-min-sdk-version\": $$emitString($$ANDROID_MIN_SDK_VERSION)," + + !isEmpty(ANDROID_TARGET_SDK_VERSION): \ + FILE_CONTENT += " \"android-target-sdk-version\": $$emitString($$ANDROID_TARGET_SDK_VERSION)," + !isEmpty(ANDROID_EXTRA_LIBS): \ FILE_CONTENT += " \"android-extra-libs\": $$emitString($$join(ANDROID_EXTRA_LIBS, ","))," diff --git a/qmake/doc/src/qmake-manual.qdoc b/qmake/doc/src/qmake-manual.qdoc index 1e1e23495c0..351009bd1c6 100644 --- a/qmake/doc/src/qmake-manual.qdoc +++ b/qmake/doc/src/qmake-manual.qdoc @@ -1111,6 +1111,15 @@ \row \li designer \li The target is a plugin for \QD. \row \li no_lflags_merge \li Ensures that the list of libraries stored in the \c LIBS variable is not reduced to a list of unique values before it is used. + \row \li metatypes \li Create a \c {_metatypes.json} file for the + current project. \c {} is the all lowercase base name of + \l TARGET. + \row \li qmltypes \li Automatically register QML types defined in C++. + For more information, see \l {Defining QML Types from C++}. + Also, create a \c {