Examples: Remove a redundant virtual specifier for overriders
It's a good practice to use override without virtual: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-override Change-Id: I5c2d73600e6c706424589c0487133c03a4ef3629 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
f91bbd2438
commit
011aeb131e
@ -67,12 +67,12 @@ public:
|
||||
painter->drawPixmap(QPointF(), p);
|
||||
}
|
||||
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *) override
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *) override
|
||||
{
|
||||
emit clicked();
|
||||
}
|
||||
|
||||
virtual void setGeometry(const QRectF &rect) override
|
||||
void setGeometry(const QRectF &rect) override
|
||||
{
|
||||
QGraphicsWidget::setGeometry(rect);
|
||||
|
||||
@ -98,7 +98,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *) override
|
||||
void resizeEvent(QResizeEvent *) override
|
||||
{
|
||||
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
@ -98,14 +98,14 @@ public:
|
||||
|
||||
protected:
|
||||
//![14]
|
||||
virtual bool eventTest(QEvent *event) override
|
||||
bool eventTest(QEvent *event) override
|
||||
{
|
||||
return (event->type() == QEvent::Type(StateSwitchEvent::StateSwitchType))
|
||||
&& (static_cast<StateSwitchEvent *>(event)->rand() == m_rand);
|
||||
}
|
||||
//![14]
|
||||
|
||||
virtual void onTransition(QEvent *) override {}
|
||||
void onTransition(QEvent *) override {}
|
||||
|
||||
private:
|
||||
int m_rand;
|
||||
@ -122,7 +122,7 @@ public:
|
||||
//![10]
|
||||
|
||||
//![11]
|
||||
virtual void onEntry(QEvent *) override
|
||||
void onEntry(QEvent *) override
|
||||
{
|
||||
int n;
|
||||
while ((n = (qrand() % m_stateCount + 1)) == m_lastIndex)
|
||||
@ -130,7 +130,7 @@ public:
|
||||
m_lastIndex = n;
|
||||
machine()->postEvent(new StateSwitchEvent(n));
|
||||
}
|
||||
virtual void onExit(QEvent *) override {}
|
||||
void onExit(QEvent *) override {}
|
||||
//![11]
|
||||
|
||||
//![12]
|
||||
@ -174,7 +174,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override
|
||||
void resizeEvent(QResizeEvent *event) override
|
||||
{
|
||||
fitInView(scene()->sceneRect());
|
||||
QGraphicsView::resizeEvent(event);
|
||||
|
@ -79,7 +79,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *) override
|
||||
void resizeEvent(QResizeEvent *) override
|
||||
{
|
||||
fitInView(sceneRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public:
|
||||
GraphicsView(QWidget *parent = 0);
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *) override;
|
||||
|
||||
signals:
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
setTargetState(target);
|
||||
}
|
||||
|
||||
virtual bool eventTest(QEvent *e) override
|
||||
bool eventTest(QEvent *e) override
|
||||
{
|
||||
if (QSignalTransition::eventTest(e)) {
|
||||
QVariant key = static_cast<QStateMachine::SignalEvent*>(e)->arguments().at(0);
|
||||
@ -95,7 +95,7 @@ public:
|
||||
startTimer(1000);
|
||||
}
|
||||
|
||||
virtual bool eventTest(QEvent *e) override
|
||||
bool eventTest(QEvent *e) override
|
||||
{
|
||||
return QEventTransition::eventTest(e) && ((qrand() % 50) == 0);
|
||||
}
|
||||
|
@ -60,13 +60,13 @@ public:
|
||||
RectButton(QString buttonText);
|
||||
~RectButton();
|
||||
|
||||
virtual QRectF boundingRect() const override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
protected:
|
||||
QString m_ButtonText;
|
||||
|
||||
virtual void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
void mousePressEvent (QGraphicsSceneMouseEvent *event) override;
|
||||
|
||||
signals:
|
||||
void clicked();
|
||||
|
@ -69,8 +69,8 @@ public:
|
||||
StickMan();
|
||||
~StickMan();
|
||||
|
||||
virtual QRectF boundingRect() const override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
int nodeCount() const;
|
||||
Node *node(int idx) const;
|
||||
|
@ -86,7 +86,7 @@ public:
|
||||
|
||||
void updateBoatMovement();
|
||||
|
||||
virtual int type() const override;
|
||||
int type() const override;
|
||||
|
||||
signals:
|
||||
void boatDestroyed();
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
{
|
||||
}
|
||||
protected:
|
||||
virtual bool eventTest(QEvent *event) override
|
||||
bool eventTest(QEvent *event) override
|
||||
{
|
||||
if (!QKeyEventTransition::eventTest(event))
|
||||
return false;
|
||||
@ -100,7 +100,7 @@ public:
|
||||
{
|
||||
}
|
||||
protected:
|
||||
virtual bool eventTest(QEvent *event) override
|
||||
bool eventTest(QEvent *event) override
|
||||
{
|
||||
if (!QKeyEventTransition::eventTest(event))
|
||||
return false;
|
||||
@ -131,7 +131,7 @@ public:
|
||||
{
|
||||
}
|
||||
protected:
|
||||
virtual bool eventTest(QEvent *event) override
|
||||
bool eventTest(QEvent *event) override
|
||||
{
|
||||
if (!QKeyEventTransition::eventTest(event))
|
||||
return false;
|
||||
|
@ -152,7 +152,7 @@ class UpdateScoreTransition : public QSignalTransition
|
||||
public:
|
||||
UpdateScoreTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target);
|
||||
protected:
|
||||
virtual bool eventTest(QEvent *event) override;
|
||||
bool eventTest(QEvent *event) override;
|
||||
private:
|
||||
PlayState * game;
|
||||
GraphicsScene *scene;
|
||||
@ -164,7 +164,7 @@ class WinTransition : public QSignalTransition
|
||||
public:
|
||||
WinTransition(GraphicsScene *scene, PlayState *game, QAbstractState *target);
|
||||
protected:
|
||||
virtual bool eventTest(QEvent *event) override;
|
||||
bool eventTest(QEvent *event) override;
|
||||
private:
|
||||
PlayState * game;
|
||||
GraphicsScene *scene;
|
||||
@ -176,7 +176,7 @@ private:
|
||||
public:
|
||||
CustomSpaceTransition(QWidget *widget, PlayState *game, QEvent::Type type, int key);
|
||||
protected:
|
||||
virtual bool eventTest(QEvent *event) override;
|
||||
bool eventTest(QEvent *event) override;
|
||||
private:
|
||||
PlayState *game;
|
||||
};
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
void launchTorpedo(int speed);
|
||||
void destroy();
|
||||
|
||||
virtual int type() const override;
|
||||
int type() const override;
|
||||
|
||||
QGraphicsRotation *rotation() const { return graphicsRotation; }
|
||||
|
||||
|
@ -110,8 +110,8 @@ public:
|
||||
GLTexture2D(int width, int height);
|
||||
explicit GLTexture2D(const QString& fileName, int width = 0, int height = 0);
|
||||
void load(int width, int height, QRgb *data);
|
||||
virtual void bind() override;
|
||||
virtual void unbind() override;
|
||||
void bind() override;
|
||||
void unbind() override;
|
||||
};
|
||||
|
||||
class GLTexture3D : public GLTexture
|
||||
@ -121,8 +121,8 @@ public:
|
||||
// TODO: Implement function below
|
||||
//GLTexture3D(const QString& fileName, int width = 0, int height = 0);
|
||||
void load(int width, int height, int depth, QRgb *data);
|
||||
virtual void bind() override;
|
||||
virtual void unbind() override;
|
||||
void bind() override;
|
||||
void unbind() override;
|
||||
};
|
||||
|
||||
class GLTextureCube : public GLTexture
|
||||
@ -131,8 +131,8 @@ public:
|
||||
GLTextureCube(int size);
|
||||
explicit GLTextureCube(const QStringList& fileNames, int size = 0);
|
||||
void load(int size, int face, QRgb *data);
|
||||
virtual void bind() override;
|
||||
virtual void unbind() override;
|
||||
void bind() override;
|
||||
void unbind() override;
|
||||
};
|
||||
|
||||
// TODO: Define and implement class below
|
||||
|
@ -63,18 +63,18 @@ public:
|
||||
|
||||
ItemBase(int size, int x, int y);
|
||||
virtual ~ItemBase();
|
||||
virtual QRectF boundingRect() const override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QRectF boundingRect() const override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
protected:
|
||||
virtual ItemBase *createNew(int size, int x, int y) = 0;
|
||||
virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void keyPressEvent(QKeyEvent *event) override;
|
||||
virtual void wheelEvent(QGraphicsSceneWheelEvent *event) override;
|
||||
virtual int type() const override;
|
||||
void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void keyPressEvent(QKeyEvent *event) override;
|
||||
void wheelEvent(QGraphicsSceneWheelEvent *event) override;
|
||||
int type() const override;
|
||||
bool isInResizeArea(const QPointF &pos);
|
||||
|
||||
static void duplicateSelectedItems(QGraphicsScene *scene);
|
||||
@ -92,9 +92,9 @@ class QtBox : public ItemBase
|
||||
public:
|
||||
QtBox(int size, int x, int y);
|
||||
virtual ~QtBox();
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
protected:
|
||||
virtual ItemBase *createNew(int size, int x, int y) override;
|
||||
ItemBase *createNew(int size, int x, int y) override;
|
||||
private:
|
||||
QVector3D m_vertices[8];
|
||||
QVector3D m_texCoords[4];
|
||||
@ -106,9 +106,9 @@ class CircleItem : public ItemBase
|
||||
{
|
||||
public:
|
||||
CircleItem(int size, int x, int y);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
protected:
|
||||
virtual ItemBase *createNew(int size, int x, int y) override;
|
||||
ItemBase *createNew(int size, int x, int y) override;
|
||||
|
||||
QColor m_color;
|
||||
};
|
||||
@ -117,9 +117,9 @@ class SquareItem : public ItemBase
|
||||
{
|
||||
public:
|
||||
SquareItem(int size, int x, int y);
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
protected:
|
||||
virtual ItemBase *createNew(int size, int x, int y) override;
|
||||
ItemBase *createNew(int size, int x, int y) override;
|
||||
|
||||
QPixmap m_image;
|
||||
};
|
||||
|
@ -87,7 +87,7 @@ public slots:
|
||||
signals:
|
||||
void colorChanged(QRgb color, int id);
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
void mousePressEvent(QMouseEvent *event) override;
|
||||
void setColor(QRgb color); // also emits colorChanged()
|
||||
private:
|
||||
QGraphicsScene *m_dialogParentScene;
|
||||
@ -120,9 +120,9 @@ class GraphicsWidget : public QGraphicsProxyWidget
|
||||
public:
|
||||
GraphicsWidget() : QGraphicsProxyWidget(0, Qt::Window) {}
|
||||
protected:
|
||||
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
virtual void resizeEvent(QGraphicsSceneResizeEvent *event) override;
|
||||
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
void resizeEvent(QGraphicsSceneResizeEvent *event) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
};
|
||||
|
||||
class TwoSidedGraphicsWidget : public QObject
|
||||
@ -162,7 +162,7 @@ signals:
|
||||
void shaderChanged(int);
|
||||
void doubleClicked();
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
|
||||
QVector<QByteArray> m_parameterNames;
|
||||
QComboBox *m_textureCombo;
|
||||
@ -189,7 +189,7 @@ signals:
|
||||
void doubleClicked();
|
||||
void newItemTriggered(ItemDialog::ItemType type);
|
||||
protected:
|
||||
virtual void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
||||
};
|
||||
|
||||
class Scene : public QGraphicsScene
|
||||
@ -198,7 +198,7 @@ class Scene : public QGraphicsScene
|
||||
public:
|
||||
Scene(int width, int height, int maxTextureSize);
|
||||
~Scene();
|
||||
virtual void drawBackground(QPainter *painter, const QRectF &rect) override;
|
||||
void drawBackground(QPainter *painter, const QRectF &rect) override;
|
||||
|
||||
public slots:
|
||||
void setShader(int index);
|
||||
@ -214,10 +214,10 @@ protected:
|
||||
void defaultStates();
|
||||
void renderCubemaps();
|
||||
|
||||
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
virtual void wheelEvent(QGraphicsSceneWheelEvent * event) override;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
void wheelEvent(QGraphicsSceneWheelEvent * event) override;
|
||||
private:
|
||||
void initGL();
|
||||
QPointF pixelPosToViewPos(const QPointF& p);
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *) override
|
||||
void resizeEvent(QResizeEvent *) override
|
||||
{
|
||||
}
|
||||
};
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
virtual void resizeEvent(QResizeEvent *event) override
|
||||
void resizeEvent(QResizeEvent *event) override
|
||||
{
|
||||
w->setGeometry(0, 0, event->size().width(), event->size().height());
|
||||
}
|
||||
|
@ -63,8 +63,8 @@ public:
|
||||
|
||||
|
||||
protected:
|
||||
virtual void resizeEvent(QResizeEvent *event) override;
|
||||
virtual QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
QModelIndex moveCursor(CursorAction cursorAction, Qt::KeyboardModifiers modifiers) override;
|
||||
void scrollTo (const QModelIndex & index, ScrollHint hint = EnsureVisible) override;
|
||||
|
||||
private:
|
||||
|
@ -78,7 +78,7 @@ public slots:
|
||||
void fileNew();
|
||||
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *e) override;
|
||||
void closeEvent(QCloseEvent *e) override;
|
||||
|
||||
private slots:
|
||||
void fileOpen();
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
: QSignalTransition(fact, SIGNAL(xChanged(int))), m_fact(fact)
|
||||
{}
|
||||
|
||||
virtual bool eventTest(QEvent *e) override
|
||||
bool eventTest(QEvent *e) override
|
||||
{
|
||||
if (!QSignalTransition::eventTest(e))
|
||||
return false;
|
||||
@ -111,7 +111,7 @@ public:
|
||||
return se->arguments().at(0).toInt() > 1;
|
||||
}
|
||||
|
||||
virtual void onTransition(QEvent *e) override
|
||||
void onTransition(QEvent *e) override
|
||||
{
|
||||
QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(e);
|
||||
int x = se->arguments().at(0).toInt();
|
||||
@ -133,7 +133,7 @@ public:
|
||||
: QSignalTransition(fact, SIGNAL(xChanged(int))), m_fact(fact)
|
||||
{}
|
||||
|
||||
virtual bool eventTest(QEvent *e) override
|
||||
bool eventTest(QEvent *e) override
|
||||
{
|
||||
if (!QSignalTransition::eventTest(e))
|
||||
return false;
|
||||
@ -141,7 +141,7 @@ public:
|
||||
return se->arguments().at(0).toInt() <= 1;
|
||||
}
|
||||
|
||||
virtual void onTransition(QEvent *) override
|
||||
void onTransition(QEvent *) override
|
||||
{
|
||||
fprintf(stdout, "%d\n", m_fact->property("fac").toInt());
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
: QState(parent) {}
|
||||
|
||||
protected:
|
||||
virtual void onEntry(QEvent *) override
|
||||
void onEntry(QEvent *) override
|
||||
{
|
||||
machine()->postEvent(new PingEvent());
|
||||
fprintf(stdout, "ping?\n");
|
||||
@ -93,7 +93,7 @@ protected:
|
||||
virtual bool eventTest(QEvent *e) override {
|
||||
return (e->type() == QEvent::User+3);
|
||||
}
|
||||
virtual void onTransition(QEvent *) override
|
||||
void onTransition(QEvent *) override
|
||||
{
|
||||
machine()->postDelayedEvent(new PingEvent(), 500);
|
||||
fprintf(stdout, "ping?\n");
|
||||
@ -111,7 +111,7 @@ protected:
|
||||
virtual bool eventTest(QEvent *e) override {
|
||||
return (e->type() == QEvent::User+2);
|
||||
}
|
||||
virtual void onTransition(QEvent *) override
|
||||
void onTransition(QEvent *) override
|
||||
{
|
||||
machine()->postDelayedEvent(new PongEvent(), 500);
|
||||
fprintf(stdout, "pong!\n");
|
||||
|
@ -74,7 +74,7 @@ public slots:
|
||||
void turnOn() { setOn(true); }
|
||||
|
||||
protected:
|
||||
virtual void paintEvent(QPaintEvent *) override
|
||||
void paintEvent(QPaintEvent *) override
|
||||
{
|
||||
if (!m_on)
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user