There is no recursion class member function definition.
class SimpleDelegate : public QStyledItemDelegate { public: void paint(QPainter* pPainter, const QStyleOptionViewItem& option, const QModelIndex& index ) const ...... условие_выхода ...... { QStyledItemDelegate::paint(pPainter, option, index); // рекурсия ? } };
There are two different functions. One function is SimpleDelegate::paint , the other function is QStyledItemDelegate::paint .
The first function in the definition domain of the derived class hides the declaration of the second function with the same name in the base class. Therefore, if you want to call the base class function of the same name from the function of the derived class, you need to specify its qualified name, which is done in the given example.
View this demo.
#include <iostream> #include <string> int main() { struct A { void f(const char *) const { std::cout << "Hello"; } void f(char) const { std::cout << ' '; } }; struct B : A { void f(const std::string &s ) const { A::f(nullptr); A::f(' '); std::cout << s << std::endl; } }; B().f(std::string("perfect")); return 0; }
Its output to the console
Hello perfect
Here the function declared in the derived class B hides the functions of the same name declared in the base class A Therefore, to refer to these functions of the base class in the domain of the derived class, you should use the qualified names of the functions of the base class.
Another alternative approach, provided that there is no ambiguity in overloading functions, is to use using declarations in a derived class. For example,
struct B : A { using A::f; void f(const std::string &s ) const { f(nullptr); f(' '); std::cout << s << std::endl; } };
However, if the signatures of the functions of the same name in the base and derived classes are the same, then, in order to eliminate ambiguity, it is necessary to explicitly indicate the qualified names of functions for the base class.