diff options
Diffstat (limited to 'examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp')
-rw-r--r-- | examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp index b0c3733b22..bb1f83482b 100644 --- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp +++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. @@ -73,6 +73,8 @@ MandelbrotWidget::MandelbrotWidget(QWidget *parent) : pixmapScale(DefaultScale), curScale(DefaultScale) { + help = tr("Use mouse wheel or the '+' and '-' keys to zoom. " + "Press and hold left mouse button to scroll."); connect(&thread, &RenderThread::renderedImage, this, &MandelbrotWidget::updatePixmap); @@ -80,8 +82,6 @@ MandelbrotWidget::MandelbrotWidget(QWidget *parent) : #if QT_CONFIG(cursor) setCursor(Qt::CrossCursor); #endif - resize(550, 400); - } //! [1] @@ -127,8 +127,9 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */) } //! [8] //! [9] - QString text = tr("Use mouse wheel or the '+' and '-' keys to zoom. " - "Press and hold left mouse button to scroll."); + QString text = help; + if (!info.isEmpty()) + text += ' ' + info; QFontMetrics metrics = painter.fontMetrics(); int textWidth = metrics.horizontalAdvance(text); @@ -169,6 +170,9 @@ void MandelbrotWidget::keyPressEvent(QKeyEvent *event) case Qt::Key_Up: scroll(0, +ScrollStep); break; + case Qt::Key_Q: + close(); + break; default: QWidget::keyPressEvent(event); } @@ -226,6 +230,8 @@ void MandelbrotWidget::updatePixmap(const QImage &image, double scaleFactor) if (!lastDragPos.isNull()) return; + info = image.text(RenderThread::infoKey()); + pixmap = QPixmap::fromImage(image); pixmapOffset = QPoint(); lastDragPos = QPoint(); |