doc: Add missing override and remove redundant virtual for snippets

Change-Id: I2395fd01b93c4ea364225e0cf1a5f59908b691d0
Reviewed-by: Martin Smith <martin.smith@qt.io>
This commit is contained in:
Alexander Volkov 2016-12-08 00:23:14 +03:00
parent 9b59a2ef97
commit 242ea38375
37 changed files with 95 additions and 95 deletions

View File

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

View File

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

View File

@ -94,7 +94,7 @@ class SandboxProcess : public QProcess
{
...
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)
return QSortFilterProxyModel::data(index, role);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -146,7 +146,7 @@ public:
protected:
void initializeGL()
void initializeGL() override
{
// 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.:
glViewport(0, 0, (GLint)w, (GLint)h);
@ -164,7 +164,7 @@ protected:
...
}
void paintGL()
void paintGL() override
{
// draw the scene:
...

View File

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

View File

@ -55,7 +55,7 @@ public:
MyGLWidget(QWidget *parent) : QOpenGLWidget(parent) { }
protected:
void initializeGL()
void initializeGL() override
{
// Set up the rendering context, load shaders and other resources, etc.:
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:
m_projection.setToIdentity();
@ -71,7 +71,7 @@ protected:
...
}
void paintGL()
void paintGL() override
{
// Draw the scene:
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
@ -86,7 +86,7 @@ protected:
class MyGLWidget : public QOpenGLWidget, protected QOpenGLFunctions
{
...
void initializeGL()
void initializeGL() override
{
initializeOpenGLFunctions();
glClearColor(...);
@ -108,7 +108,7 @@ widget->setFormat(format); // must be called before the widget or its parent win
//! [3]
...
void paintGL()
void paintGL() override
{
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();
void addItem(QLayoutItem *item);
QSize sizeHint() const;
QSize minimumSize() const;
int count() const;
QLayoutItem *itemAt(int) const;
QLayoutItem *takeAt(int);
void setGeometry(const QRect &rect);
void addItem(QLayoutItem *item) override;
QSize sizeHint() const override;
QSize minimumSize() const override;
int count() const override;
QLayoutItem *itemAt(int) const override;
QLayoutItem *takeAt(int) override;
void setGeometry(const QRect &rect) override;
private:
QList<QLayoutItem*> list;

View File

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

View File

@ -54,7 +54,7 @@ class MyProxyStyle : public QProxyStyle
public:
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)
return 1;
@ -73,7 +73,7 @@ class MyProxyStyle : public QProxyStyle
{
public:
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)
return 0;

View File

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

View File

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

View File

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

View File

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

View File

@ -61,15 +61,15 @@ class DragDropListModel : public QStringListModel
public:
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,
int row, int column, const QModelIndex &parent);
int row, int column, const QModelIndex &parent) override;
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
int row, int column, const QModelIndex &parent);
QMimeData *mimeData(const QModelIndexList &indexes) const;
QStringList mimeTypes() const;
Qt::DropActions supportedDropActions() const;
int row, int column, const QModelIndex &parent) override;
QMimeData *mimeData(const QModelIndexList &indexes) const override;
QStringList mimeTypes() const override;
Qt::DropActions supportedDropActions() const override;
};
#endif

View File

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

View File

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

View File

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

View File

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