Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
Back to tool/Back to issues
#7726·supercollider

"No such method addChild(QWidget*)" warning spam

Author: Xon77Created Sep 23, 2026Updated Sep 23, 2026
Labelsbug

Hello,

This message was written with the help of AI to solve an issue, where creating a gui generates errors in the post window. I do not know if it the best way to solve it. But with this fix, there is no longer error messages in the post window.

Environment

  • SuperCollider version: Latest Dev
  • Operating system: MacOS 27
  • Other details (Qt version, audio driver, etc.): Qt 6.8 & 6.11.2

Steps to reproduce

supercollider
(
var wA = Window.new("Window A", Rect(100, 100, 220, 150)).front;
var wB = Window.new("Window B", Rect(340, 100, 220, 150)).front;
var container = View(wB, Rect(10, 10, 200, 120)); // plain View: no addChild slot
var btn = Button(wA, Rect(10, 10, 200, 24)).string_("Click to move me to Window B");
btn.action = {
	btn.setParent(container);
	btn.bounds = Rect(10, 10, 180, 24);
	btn.visible = true;
};
)

Click the button. The Post Window prints, at the exact moment of the click:

ERROR: QMetaObject::invokeMethod: No such method QcDefaultWidget::addChild(QWidget*)

Problem

Function: QWidgetProxy::setParent()

cpp
bool ok = pw->metaObject()->invokeMethod(pw, "addChild", Q_ARG(QWidget*, widget()));
if (!ok)
    widget()->setParent(pw);

invokeMethod() calls "addChild" blind. When the target widget has no such slot (any plain View), Qt itself prints the warning to stderr before invokeMethod() returns false — the fallback on the next line (widget()->setParent(pw)) already handles this case correctly, but the warning has already fired by then. QcWidgetFactory::newInstance() elsewhere in this same file already guards an equivalent call with indexOfMethod() first; this path just didn't get the same treatment.

Possible Fix

File to modify: QtCollider/QWidgetProxy.cpp Function: QWidgetProxy::setParent() Change: replace the blind invokeMethod() call with a guarded one. Nothing else in the function changes.

diff
     if (parent->isWidgetType()) {
         QWidget* pw = qobject_cast<QWidget*>(parent);
-        bool ok = pw->metaObject()->invokeMethod(pw, "addChild", Q_ARG(QWidget*, widget()));
+        int mi = pw->metaObject()->indexOfMethod("addChild(QWidget*)");
+        bool ok = (mi >= 0) && pw->metaObject()->method(mi).invoke(pw, Q_ARG(QWidget*, widget()));
         if (!ok)
             widget()->setParent(pw);
         return true;
     }

Also requires one more change, or the build fails: add one new include line, right after #include <QFontMetrics> and before #include <QUrl> in this file's existing include block:

diff
 #include <QApplication>
 #include <QLayout>
 #include <QMouseEvent>
 #include <QKeyEvent>
 #include <QPainter>
 #include <QFontMetrics>
+#include <QMetaMethod>
 #include <QUrl>
 #include <QMimeData>
 #include <QDrag>

Without it, the build fails with: error: calling 'method' with incomplete return type 'QMetaMethod' because QMetaObject::method() (used above) returns a QMetaMethod by value, and this file's existing includes only carry a forward declaration of that type, not its full definition.

Source: supercollider/supercollider

View original on GitHubView discussion on GitHub