diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index b0442e0a2a9..afc777be1a8 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -3302,9 +3302,17 @@ public: // Write class qualification, if any. if (matchingClass) { - const Name *name = rewriteName(matchingClass->name(), &env, control); - funcDef.append(printer.prettyName(name)); - funcDef.append(QLatin1String("::")); + Class *current = matchingClass; + QVector classes{matchingClass->name()}; + while (current->enclosingScope()->asClass()) { + current = current->enclosingScope()->asClass(); + classes.prepend(current->name()); + } + for (const Name *n : classes) { + const Name *name = rewriteName(n, &env, control); + funcDef.append(printer.prettyName(name)); + funcDef.append(QLatin1String("::")); + } } // Write the extracted function itself and its call.