Answer the question
In order to leave comments, you need to log in
What does "Q_DECL_OVERRIDE" do in Qt?
I understand Qt, here I was reviewing a simple project in parts and ran into a strange function declaration:
For example: void advance(int step) Q_DECL_OVERRIDE;
or: QRectF boundingRect() const Q_DECL_OVERRIDE;
I looked on the Qt website why this macro is needed, as I understand it, to generate errors for non-overridden virtual functions.
But here the functions are not virtual at all. Explain who knows what the macro "Q_DECL_OVERRIDE" is and why it is needed?
Answer the question
In order to leave comments, you need to log in
This macro expands as override if there is C++11 support, and as empty space otherwise. What is actually written on the site: "It expands to "override" if your compiler supports that C++11 contextual keyword, or to nothing otherwise".
What the override keyword means can be easily Googled: en.cppreference.com/w/cpp/language/override.
For virtual functions, it is good practice to write the word virtual only once - usually in the interface, this does not stop them from being virtual. In other cases, override.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question