Merge remote-tracking branch 'origin/5.11' into dev

Change-Id: I8bb8227f9da982e7d5ebe5324fc27abd9ac0d4fc
This commit is contained in:
Qt Forward Merge Bot 2018-08-17 09:08:04 +02:00
commit 8842d9d1e6
44 changed files with 146 additions and 110 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -51,7 +51,7 @@
//! [0] //! [0]
class HelloWorldTask : public QRunnable class HelloWorldTask : public QRunnable
{ {
void run() void run() override
{ {
qDebug() << "Hello world from thread" << QThread::currentThread(); qDebug() << "Hello world from thread" << QThread::currentThread();
} }

View File

@ -52,7 +52,7 @@
class ZipEngineHandler : public QAbstractFileEngineHandler class ZipEngineHandler : public QAbstractFileEngineHandler
{ {
public: public:
QAbstractFileEngine *create(const QString &fileName) const; QAbstractFileEngine *create(const QString &fileName) const override;
}; };
QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const
@ -105,12 +105,12 @@ public:
entries << "entry1" << "entry2" << "entry3"; entries << "entry1" << "entry2" << "entry3";
} }
bool hasNext() const bool hasNext() const override
{ {
return index < entries.size() - 1; return index < entries.size() - 1;
} }
QString next() QString next() override
{ {
if (!hasNext()) if (!hasNext())
return QString(); return QString();
@ -118,7 +118,7 @@ public:
return currentFilePath(); return currentFilePath();
} }
QString currentFileName() QString currentFileName() override
{ {
return entries.at(index); return entries.at(index);
} }

View File

@ -94,7 +94,7 @@ class SandboxProcess : public QProcess
{ {
... ...
protected: protected:
void setupChildProcess(); void setupChildProcess() override;
... ...
}; };

View File

@ -120,7 +120,7 @@ public:
... ...
QVariant data(const QModelIndex &index, int role) QVariant data(const QModelIndex &index, int role) override
{ {
if (role != Qt::BackgroundRole) if (role != Qt::BackgroundRole)
return QSortFilterProxyModel::data(index, role); return QSortFilterProxyModel::data(index, role);

View File

@ -101,7 +101,7 @@ public:
MainWindow(); MainWindow();
protected: protected:
bool eventFilter(QObject *obj, QEvent *ev); bool eventFilter(QObject *obj, QEvent *ev) override;
private: private:
QTextEdit *textEdit; QTextEdit *textEdit;
@ -147,7 +147,7 @@ public:
MyObject(QObject *parent = 0); MyObject(QObject *parent = 0);
protected: protected:
void timerEvent(QTimerEvent *event); void timerEvent(QTimerEvent *event) override;
}; };
MyObject::MyObject(QObject *parent) MyObject::MyObject(QObject *parent)
@ -215,7 +215,7 @@ class KeyPressEater : public QObject
... ...
protected: protected:
bool eventFilter(QObject *obj, QEvent *event); bool eventFilter(QObject *obj, QEvent *event) override;
}; };
bool KeyPressEater::eventFilter(QObject *obj, QEvent *event) bool KeyPressEater::eventFilter(QObject *obj, QEvent *event)
@ -508,7 +508,7 @@ public:
MyClass(QWidget *parent = 0); MyClass(QWidget *parent = 0);
~MyClass(); ~MyClass();
bool event(QEvent* ev) bool event(QEvent* ev) override
{ {
if (ev->type() == QEvent::PolishRequest) { if (ev->type() == QEvent::PolishRequest) {
// overwrite handling of PolishRequest if any // overwrite handling of PolishRequest if any

View File

@ -53,8 +53,8 @@
class MyException : public QException class MyException : public QException
{ {
public: public:
void raise() const { throw *this; } void raise() const override { throw *this; }
MyException *clone() const { return new MyException(*this); } MyException *clone() const override { return new MyException(*this); }
}; };
//! [0] //! [0]

View File

@ -58,7 +58,7 @@ class DateFormatProxyModel : public QIdentityProxyModel
m_formatString = formatString; m_formatString = formatString;
} }
QVariant data(const QModelIndex &index, int role) const QVariant data(const QModelIndex &index, int role) const override
{ {
if (role != Qt::DisplayRole) if (role != Qt::DisplayRole)
return QIdentityProxyModel::data(index, role); return QIdentityProxyModel::data(index, role);

View File

@ -59,7 +59,7 @@ class FilterObject : public QObject
public: public:
FilterObject(QObject *parent = 0); FilterObject(QObject *parent = 0);
bool eventFilter(QObject *object, QEvent *event); bool eventFilter(QObject *object, QEvent *event) override;
void setFilteredObject(QObject *object); void setFilteredObject(QObject *object);
private: private:

View File

@ -54,7 +54,7 @@
class MyCheckBox : public QCheckBox class MyCheckBox : public QCheckBox
{ {
public: public:
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event) override;
}; };
//! [0] //! [0]
@ -72,7 +72,7 @@ void MyCheckBox::mousePressEvent(QMouseEvent *event)
class MyWidget : public QWidget class MyWidget : public QWidget
{ {
public: public:
bool event(QEvent *event); bool event(QEvent *event) override;
}; };
static const int MyCustomEventType = 1099; static const int MyCustomEventType = 1099;

View File

@ -143,7 +143,7 @@ public:
void readSettings(); void readSettings();
protected: protected:
void closeEvent(QCloseEvent *event); void closeEvent(QCloseEvent *event) override;
}; };
//! [16] //! [16]

View File

@ -58,7 +58,7 @@ public:
protected: protected:
//![0] //![0]
bool eventTest(QEvent *event) bool eventTest(QEvent *event) override
{ {
if (event->type() == QEvent::Wrapped) { if (event->type() == QEvent::Wrapped) {
QEvent *wrappedEvent = static_cast<QStateMachine::WrappedEvent *>(event)->event(); QEvent *wrappedEvent = static_cast<QStateMachine::WrappedEvent *>(event)->event();
@ -71,7 +71,7 @@ protected:
} }
//![0] //![0]
void onTransition(QEvent *event) void onTransition(QEvent *event) override
{ {
} }

View File

@ -72,7 +72,7 @@ public:
: m_value(value) {} : m_value(value) {}
protected: protected:
virtual bool eventTest(QEvent *e) bool eventTest(QEvent *e) override
{ {
if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent if (e->type() != QEvent::Type(QEvent::User+1)) // StringEvent
return false; return false;
@ -80,7 +80,7 @@ protected:
return (m_value == se->value); return (m_value == se->value);
} }
virtual void onTransition(QEvent *) {} void onTransition(QEvent *) override {}
private: private:
QString m_value; QString m_value;

View File

@ -65,7 +65,7 @@ extern Q_AUTOTEST_EXPORT int qt_urlRecode(QString &appendTo, const QChar *begin,
enum AceLeadingDot { AllowLeadingDot, ForbidLeadingDot }; enum AceLeadingDot { AllowLeadingDot, ForbidLeadingDot };
enum AceOperation { ToAceOnly, NormalizeAce }; enum AceOperation { ToAceOnly, NormalizeAce };
extern QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot); extern QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot);
extern Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from); extern Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from);
extern Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len); extern Q_AUTOTEST_EXPORT bool qt_check_std3rules(const QChar *uc, int len);
extern Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString *output); extern Q_AUTOTEST_EXPORT void qt_punycodeEncoder(const QChar *s, int ucLength, QString *output);
extern Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc); extern Q_AUTOTEST_EXPORT QString qt_punycodeDecoder(const QString &pc);

View File

@ -2021,7 +2021,7 @@ static bool isBidirectionalL(uint uc)
return false; return false;
} }
Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from) Q_AUTOTEST_EXPORT bool qt_nameprep(QString *source, int from)
{ {
QChar *src = source->data(); // causes a detach, so we're sure the only one using it QChar *src = source->data(); // causes a detach, so we're sure the only one using it
QChar *out = src + from; QChar *out = src + from;
@ -2036,7 +2036,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
} }
} }
if (out == e) if (out == e)
return; // everything was mapped easily (lowercased, actually) return true; // everything was mapped easily (lowercased, actually)
int firstNonAscii = out - src; int firstNonAscii = out - src;
// Characters unassigned in Unicode 3.2 are not allowed in "stored string" scheme // Characters unassigned in Unicode 3.2 are not allowed in "stored string" scheme
@ -2059,7 +2059,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
QChar::UnicodeVersion version = QChar::unicodeVersion(uc); QChar::UnicodeVersion version = QChar::unicodeVersion(uc);
if (version == QChar::Unicode_Unassigned || version > QChar::Unicode_3_2) { if (version == QChar::Unicode_Unassigned || version > QChar::Unicode_3_2) {
source->resize(from); // not allowed, clear the label source->resize(from); // not allowed, clear the label
return; return false;
} }
} }
if (!isMappedToNothing(uc)) { if (!isMappedToNothing(uc)) {
@ -2086,7 +2086,7 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
// Strip prohibited output // Strip prohibited output
if (containsProhibitedOuptut(source, firstNonAscii)) { if (containsProhibitedOuptut(source, firstNonAscii)) {
source->resize(from); source->resize(from);
return; return false;
} }
// Check for valid bidirectional characters // Check for valid bidirectional characters
@ -2110,9 +2110,13 @@ Q_AUTOTEST_EXPORT void qt_nameprep(QString *source, int from)
} }
if (containsRandALCat) { if (containsRandALCat) {
if (containsLCat || (!isBidirectionalRorAL(src[from].unicode()) if (containsLCat || (!isBidirectionalRorAL(src[from].unicode())
|| !isBidirectionalRorAL(e[-1].unicode()))) || !isBidirectionalRorAL(e[-1].unicode()))) {
source->resize(from); // not allowed, clear the label source->resize(from); // not allowed, clear the label
return false;
}
} }
return true;
} }
static const QChar *qt_find_nonstd3(const QChar *uc, int len, Qt::CaseSensitivity cs) static const QChar *qt_find_nonstd3(const QChar *uc, int len, Qt::CaseSensitivity cs)
@ -2553,7 +2557,8 @@ QString qt_ACE_do(const QString &domain, AceOperation op, AceLeadingDot dot)
} else { } else {
// Punycode encoding and decoding cannot be done in-place // Punycode encoding and decoding cannot be done in-place
// That means we need one or two temporaries // That means we need one or two temporaries
qt_nameprep(&result, prevLen); if (!qt_nameprep(&result, prevLen))
return QString(); // failed
labelLength = result.length() - prevLen; labelLength = result.length() - prevLen;
int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes int toReserve = labelLength + 4 + 6; // "xn--" plus some extra bytes
aceForm.resize(0); aceForm.resize(0);

View File

@ -651,6 +651,7 @@ Q_ALWAYS_INLINE uint qt_builtin_clzs(quint16 v) Q_DECL_NOTHROW
// So it's an acceptable compromise. // So it's an acceptable compromise.
#if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__) #if defined(__AVX__) || defined(__SSE4_2__) || defined(__POPCNT__)
#define QALGORITHMS_USE_BUILTIN_POPCOUNT #define QALGORITHMS_USE_BUILTIN_POPCOUNT
#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW Q_ALWAYS_INLINE uint qt_builtin_popcount(quint32 v) Q_DECL_NOTHROW
{ {
return __popcnt(v); return __popcnt(v);
@ -663,13 +664,15 @@ Q_ALWAYS_INLINE uint qt_builtin_popcount(quint16 v) Q_DECL_NOTHROW
{ {
return __popcnt16(v); return __popcnt16(v);
} }
#if Q_PROCESSOR_WORDSIZE == 8
#define QALGORITHMS_USE_BUILTIN_POPCOUNTLL
Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW Q_ALWAYS_INLINE uint qt_builtin_popcountll(quint64 v) Q_DECL_NOTHROW
{ {
#if Q_PROCESSOR_WORDSIZE == 8
return __popcnt64(v); return __popcnt64(v);
} #else
return __popcnt(quint32(v)) + __popcnt(quint32(v >> 32));
#endif // MSVC 64bit #endif // MSVC 64bit
}
#endif // __AVX__ || __SSE4_2__ || __POPCNT__ #endif // __AVX__ || __SSE4_2__ || __POPCNT__
#endif // MSVC #endif // MSVC

View File

@ -74,10 +74,10 @@ signals:
void mimeTypes(const QStringList &types); void mimeTypes(const QStringList &types);
protected: protected:
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event) override;
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event) override;
private: private:
QByteArray data; QByteArray data;

View File

@ -68,7 +68,7 @@ public:
MainWindow(QWidget *parent = 0); MainWindow(QWidget *parent = 0);
protected: protected:
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event) override;
private: private:
QLabel *iconLabel; QLabel *iconLabel;

View File

@ -67,8 +67,8 @@ public:
Window(QWidget *parent = 0); Window(QWidget *parent = 0);
protected: protected:
void dragEnterEvent(QDragEnterEvent *event); void dragEnterEvent(QDragEnterEvent *event) override;
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event) override;
private: private:
QComboBox *mimeTypeCombo; QComboBox *mimeTypeCombo;

View File

@ -67,8 +67,8 @@ public:
Window(QWidget *parent = 0); Window(QWidget *parent = 0);
protected: protected:
void dragMoveEvent(QDragMoveEvent *event); void dragMoveEvent(QDragMoveEvent *event) override;
void dropEvent(QDropEvent *event); void dropEvent(QDropEvent *event) override;
private: private:
QComboBox *mimeTypeCombo; QComboBox *mimeTypeCombo;

View File

@ -53,7 +53,7 @@
class SimpleTransformation : public QWidget class SimpleTransformation : public QWidget
{ {
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *) override;
}; };
//! [0] //! [0]
@ -73,7 +73,7 @@ void SimpleTransformation::paintEvent(QPaintEvent *)
class CombinedTransformation : public QWidget class CombinedTransformation : public QWidget
{ {
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *) override;
}; };
//! [1] //! [1]
@ -97,7 +97,7 @@ void CombinedTransformation::paintEvent(QPaintEvent *)
class BasicOperations : public QWidget class BasicOperations : public QWidget
{ {
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *) override;
}; };
//! [2] //! [2]

View File

@ -61,7 +61,7 @@ public:
Window(QWidget *parent = 0); Window(QWidget *parent = 0);
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event) override;
private: private:
QFont font; QFont font;

View File

@ -61,7 +61,7 @@ public:
{ {
} }
bool event(QEvent *event) bool event(QEvent *event) override
{ {
if (event->type() == QEvent::FileOpen) { if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event); QFileOpenEvent *openEvent = static_cast<QFileOpenEvent *>(event);

View File

@ -71,8 +71,8 @@ public:
const QPixmap *pixmap() const; const QPixmap *pixmap() const;
protected: protected:
void mouseMoveEvent(QMouseEvent *event); void mouseMoveEvent(QMouseEvent *event) override;
void mousePressEvent(QMouseEvent *event); void mousePressEvent(QMouseEvent *event) override;
private: private:
void createImage(); void createImage();

View File

@ -59,8 +59,8 @@ class TextEdit : public QTextEdit
public: public:
TextEdit(QWidget *parent=0); TextEdit(QWidget *parent=0);
bool canInsertFromMimeData( const QMimeData *source ) const; bool canInsertFromMimeData( const QMimeData *source ) const override;
void insertFromMimeData( const QMimeData *source ); void insertFromMimeData( const QMimeData *source ) override;
}; };
#endif #endif

View File

@ -53,7 +53,7 @@
class SimpleTransformation : public QWidget class SimpleTransformation : public QWidget
{ {
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *) override;
}; };
//! [0] //! [0]
@ -73,7 +73,7 @@ void SimpleTransformation::paintEvent(QPaintEvent *)
class CombinedTransformation : public QWidget class CombinedTransformation : public QWidget
{ {
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *) override;
}; };
//! [1] //! [1]
@ -97,7 +97,7 @@ void CombinedTransformation::paintEvent(QPaintEvent *)
class BasicOperations : public QWidget class BasicOperations : public QWidget
{ {
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *) override;
}; };
//! [2] //! [2]

View File

@ -55,12 +55,16 @@ QT_BEGIN_NAMESPACE
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
#define QT_RESET_GLERROR() \ #define QT_RESET_GLERROR() \
{ \ { \
while (QOpenGLContext::currentContext()->functions()->glGetError() != GL_NO_ERROR) {} \ while (true) {\
GLenum error = QOpenGLContext::currentContext()->functions()->glGetError(); \
if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST) \
break; \
} \
} }
#define QT_CHECK_GLERROR() \ #define QT_CHECK_GLERROR() \
{ \ { \
GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); \ GLenum err = QOpenGLContext::currentContext()->functions()->glGetError(); \
if (err != GL_NO_ERROR) { \ if (err != GL_NO_ERROR && err != GL_CONTEXT_LOST) { \
qDebug("[%s line %d] OpenGL Error: %d", \ qDebug("[%s line %d] OpenGL Error: %d", \
__FILE__, __LINE__, (int)err); \ __FILE__, __LINE__, (int)err); \
} \ } \
@ -134,6 +138,10 @@ QT_BEGIN_NAMESPACE
#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
#endif #endif
#ifndef GL_CONTEXT_LOST
#define GL_CONTEXT_LOST 0x0507
#endif
/*! /*!
@ -1327,8 +1335,11 @@ static QImage qt_gl_read_framebuffer(const QSize &size, GLenum internal_format,
{ {
QOpenGLContext *ctx = QOpenGLContext::currentContext(); QOpenGLContext *ctx = QOpenGLContext::currentContext();
QOpenGLFunctions *funcs = ctx->functions(); QOpenGLFunctions *funcs = ctx->functions();
while (funcs->glGetError()); while (true) {
GLenum error = funcs->glGetError();
if (error == GL_NO_ERROR || error == GL_CONTEXT_LOST)
break;
}
switch (internal_format) { switch (internal_format) {
case GL_RGB: case GL_RGB:
case GL_RGB8: case GL_RGB8:

View File

@ -146,7 +146,7 @@ public:
protected: protected:
void initializeGL() void initializeGL() override
{ {
// Set up the rendering context, define display lists etc.: // Set up the rendering context, define display lists etc.:
... ...
@ -155,7 +155,7 @@ protected:
... ...
} }
void resizeGL(int w, int h) void resizeGL(int w, int h) override
{ {
// setup viewport, projection etc.: // setup viewport, projection etc.:
glViewport(0, 0, (GLint)w, (GLint)h); glViewport(0, 0, (GLint)w, (GLint)h);
@ -164,7 +164,7 @@ protected:
... ...
} }
void paintGL() void paintGL() override
{ {
// draw the scene: // draw the scene:
... ...

View File

@ -273,7 +273,7 @@ void QSqlQueryModel_snippets()
class MyModel : public QSqlQueryModel class MyModel : public QSqlQueryModel
{ {
public: public:
QVariant data(const QModelIndex &item, int role) const; QVariant data(const QModelIndex &item, int role) const override;
int m_specialColumnNo; int m_specialColumnNo;
}; };
@ -526,15 +526,15 @@ public:
~XyzResult() {} ~XyzResult() {}
protected: protected:
QVariant data(int /* index */) { return QVariant(); } QVariant data(int /* index */) override { return QVariant(); }
bool isNull(int /* index */) { return false; } bool isNull(int /* index */) override { return false; }
bool reset(const QString & /* query */) { return false; } bool reset(const QString & /* query */) override { return false; }
bool fetch(int /* index */) { return false; } bool fetch(int /* index */) override { return false; }
bool fetchFirst() { return false; } bool fetchFirst() override { return false; }
bool fetchLast() { return false; } bool fetchLast() override { return false; }
int size() { return 0; } int size() override { return 0; }
int numRowsAffected() { return 0; } int numRowsAffected() override { return 0; }
QSqlRecord record() const { return QSqlRecord(); } QSqlRecord record() const override { return QSqlRecord(); }
}; };
//! [47] //! [47]
@ -545,13 +545,13 @@ public:
XyzDriver() {} XyzDriver() {}
~XyzDriver() {} ~XyzDriver() {}
bool hasFeature(DriverFeature /* feature */) const { return false; } bool hasFeature(DriverFeature /* feature */) const override { return false; }
bool open(const QString & /* db */, const QString & /* user */, bool open(const QString & /* db */, const QString & /* user */,
const QString & /* password */, const QString & /* host */, const QString & /* password */, const QString & /* host */,
int /* port */, const QString & /* options */) int /* port */, const QString & /* options */) override
{ return false; } { return false; }
void close() {} void close() {}
QSqlResult *createResult() const { return new XyzResult(this); } QSqlResult *createResult() const override { return new XyzResult(this); }
}; };
//! [48] //! [48]

View File

@ -55,7 +55,7 @@ public:
MyGLWidget(QWidget *parent) : QOpenGLWidget(parent) { } MyGLWidget(QWidget *parent) : QOpenGLWidget(parent) { }
protected: protected:
void initializeGL() void initializeGL() override
{ {
// Set up the rendering context, load shaders and other resources, etc.: // Set up the rendering context, load shaders and other resources, etc.:
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
@ -63,7 +63,7 @@ protected:
... ...
} }
void resizeGL(int w, int h) void resizeGL(int w, int h) override
{ {
// Update projection matrix and other size related settings: // Update projection matrix and other size related settings:
m_projection.setToIdentity(); m_projection.setToIdentity();
@ -71,7 +71,7 @@ protected:
... ...
} }
void paintGL() void paintGL() override
{ {
// Draw the scene: // Draw the scene:
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
@ -86,7 +86,7 @@ protected:
class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{ {
... ...
void initializeGL() void initializeGL() override
{ {
initializeOpenGLFunctions(); initializeOpenGLFunctions();
glClearColor(...); glClearColor(...);
@ -108,7 +108,7 @@ widget->setFormat(format); // must be called before the widget or its parent win
//! [3] //! [3]
... ...
void paintGL() void paintGL() override
{ {
QOpenGLFunctions_3_2_Core *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>(); QOpenGLFunctions_3_2_Core *f = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_3_2_Core>();
... ...

View File

@ -63,13 +63,13 @@ public:
CardLayout(int dist): QLayout(dist) {} CardLayout(int dist): QLayout(dist) {}
~CardLayout(); ~CardLayout();
void addItem(QLayoutItem *item); void addItem(QLayoutItem *item) override;
QSize sizeHint() const; QSize sizeHint() const override;
QSize minimumSize() const; QSize minimumSize() const override;
int count() const; int count() const override;
QLayoutItem *itemAt(int) const; QLayoutItem *itemAt(int) const override;
QLayoutItem *takeAt(int); QLayoutItem *takeAt(int) override;
void setGeometry(const QRect &rect); void setGeometry(const QRect &rect) override;
private: private:
QList<QLayoutItem*> list; QList<QLayoutItem*> list;

View File

@ -52,7 +52,7 @@
class SimpleItem : public QGraphicsItem class SimpleItem : public QGraphicsItem
{ {
public: public:
QRectF boundingRect() const QRectF boundingRect() const override
{ {
qreal penWidth = 1; qreal penWidth = 1;
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2, return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
@ -60,7 +60,7 @@ public:
} }
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget) QWidget *widget) override
{ {
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5); painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
} }
@ -74,7 +74,7 @@ class CustomItem : public QGraphicsItem
public: public:
enum { Type = UserType + 1 }; enum { Type = UserType + 1 };
int type() const int type() const override
{ {
// Enable the use of qgraphicsitem_cast with this item. // Enable the use of qgraphicsitem_cast with this item.
return Type; return Type;
@ -260,7 +260,7 @@ class QGraphicsPathItem : public QAbstractGraphicsShapeItem
{ {
public: public:
enum { Type = 2 }; enum { Type = 2 };
int type() const { return Type; } int type() const override { return Type; }
... ...
}; };
//! [18] //! [18]

View File

@ -54,7 +54,7 @@ class MyProxyStyle : public QProxyStyle
public: public:
int styleHint(StyleHint hint, const QStyleOption *option = 0, int styleHint(StyleHint hint, const QStyleOption *option = 0,
const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override
{ {
if (hint == QStyle::SH_UnderlineShortcut) if (hint == QStyle::SH_UnderlineShortcut)
return 1; return 1;
@ -73,7 +73,7 @@ class MyProxyStyle : public QProxyStyle
{ {
public: public:
int styleHint(StyleHint hint, const QStyleOption *option = 0, int styleHint(StyleHint hint, const QStyleOption *option = 0,
const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const const QWidget *widget = 0, QStyleHintReturn *returnData = 0) const override
{ {
if (hint == QStyle::SH_UnderlineShortcut) if (hint == QStyle::SH_UnderlineShortcut)
return 0; return 0;

View File

@ -54,9 +54,9 @@ class AppendText : public QUndoCommand
public: public:
AppendText(QString *doc, const QString &text) AppendText(QString *doc, const QString &text)
: m_document(doc), m_text(text) { setText("append text"); } : m_document(doc), m_text(text) { setText("append text"); }
virtual void undo() void undo() override
{ m_document->chop(m_text.length()); } { m_document->chop(m_text.length()); }
virtual void redo() void redo() override
{ m_document->append(m_text); } { m_document->append(m_text); }
private: private:
QString *m_document; QString *m_document;

View File

@ -63,7 +63,7 @@ public:
~CustomStyle() {} ~CustomStyle() {}
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget) const; QPainter *painter, const QWidget *widget) const override;
}; };
//! [0] //! [0]

View File

@ -58,7 +58,7 @@ public:
void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[], void drawItems(QPainter *painter, int numItems, QGraphicsItem *items[],
const QStyleOptionGraphicsItem options[], const QStyleOptionGraphicsItem options[],
QWidget *widget = 0); QWidget *widget = 0) override;
}; };
//! [0] //! [0]

View File

@ -57,8 +57,8 @@ public:
void setWidget(QWidget *w); void setWidget(QWidget *w);
protected: protected:
void scrollContentsBy(int dx, int dy); void scrollContentsBy(int dx, int dy) override;
void resizeEvent(QResizeEvent *event); void resizeEvent(QResizeEvent *event) override;
private: private:
void updateWidgetPosition(); void updateWidgetPosition();

View File

@ -61,15 +61,15 @@ class DragDropListModel : public QStringListModel
public: public:
DragDropListModel(const QStringList &strings, QObject *parent = 0); DragDropListModel(const QStringList &strings, QObject *parent = 0);
Qt::ItemFlags flags(const QModelIndex &index) const; Qt::ItemFlags flags(const QModelIndex &index) const override;
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, bool canDropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent); int row, int column, const QModelIndex &parent) override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action, bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent); int row, int column, const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const; QMimeData *mimeData(const QModelIndexList &indexes) const override;
QStringList mimeTypes() const; QStringList mimeTypes() const override;
Qt::DropActions supportedDropActions() const; Qt::DropActions supportedDropActions() const override;
}; };
#endif #endif

View File

@ -56,7 +56,7 @@ class MyPushButton : public QPushButton
public: public:
MyPushButton(QWidget *parent = 0); MyPushButton(QWidget *parent = 0);
void paintEvent(QPaintEvent *); void paintEvent(QPaintEvent *) override;
}; };
MyPushButton::MyPushButton(QWidget *parent) MyPushButton::MyPushButton(QWidget *parent)
@ -87,7 +87,7 @@ class MyStyle : public QStyle
public: public:
void drawPrimitive(PrimitiveElement element, const QStyleOption *option, void drawPrimitive(PrimitiveElement element, const QStyleOption *option,
QPainter *painter, const QWidget *widget); QPainter *painter, const QWidget *widget) override;
}; };
//! [4] //! [4]

View File

@ -59,7 +59,7 @@ class MyStylePlugin : public QStylePlugin
public: public:
MyStylePlugin(QObject *parent = 0); MyStylePlugin(QObject *parent = 0);
QStyle *create(const QString &key); QStyle *create(const QString &key) override;
}; };
//! [0] //! [0]

View File

@ -64,7 +64,7 @@ public:
Splitter(Qt::Orientation orientation, QWidget *parent = 0); Splitter(Qt::Orientation orientation, QWidget *parent = 0);
protected: protected:
QSplitterHandle *createHandle(); QSplitterHandle *createHandle() override;
}; };
//! [0] //! [0]
@ -74,7 +74,7 @@ public:
SplitterHandle(Qt::Orientation orientation, QSplitter *parent); SplitterHandle(Qt::Orientation orientation, QSplitter *parent);
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event) override;
private: private:
QLinearGradient gradient; QLinearGradient gradient;

View File

@ -55,7 +55,7 @@
class MyWidget : public QWidget class MyWidget : public QWidget
{ {
protected: protected:
void paintEvent(QPaintEvent *event); void paintEvent(QPaintEvent *event) override;
void paintEvent2(QPaintEvent *event); void paintEvent2(QPaintEvent *event);
}; };

View File

@ -2067,6 +2067,21 @@ void tst_QUrl::isValid()
qPrintable(url.errorString())); qPrintable(url.errorString()));
} }
{
QUrl url = QUrl::fromEncoded("foo://%f0%9f%93%99.example.la/g");
QVERIFY(!url.isValid());
QVERIFY(url.toString().isEmpty());
QCOMPARE(url.path(), QString("/g"));
url.setHost("%f0%9f%93%99.example.la/");
QVERIFY(!url.isValid());
QVERIFY(url.toString().isEmpty());
url.setHost("\xf0\x9f\x93\x99.example.la/");
QVERIFY(!url.isValid());
QVERIFY(url.toString().isEmpty());
QVERIFY2(url.errorString().contains("Invalid hostname"),
qPrintable(url.errorString()));
}
{ {
QUrl url("http://example.com"); QUrl url("http://example.com");
QVERIFY(url.isValid()); QVERIFY(url.isValid());
@ -2798,7 +2813,9 @@ void tst_QUrl::hosts()
{ {
QFETCH(QString, url); QFETCH(QString, url);
QTEST(QUrl(url).host(), "host"); QUrl u(url);
QTEST(u.host(), "host");
QVERIFY(u.isEmpty() || u.isValid());
} }
void tst_QUrl::hostFlags_data() void tst_QUrl::hostFlags_data()