I can set the parent's status bar text with this function I wrote
void EditorWindow::setStatusBarText(const QString& text) {
statusBar()->showMessage(text);
}
Called like this (from child)
((EditorWindow*) parent())->setStatusBarText(tr("%1, %2").arg(mousePos.x(), 0, 'f', 2).arg(mousePos.y(), 0, 'f', 2));
But I'm pretty sure that breaks a few design principles. For instance, what if parent()
is not an EditorWindow*
?
So what's the workaround for this? Force the user to pass a reference to an EditorWindow
upon creation to ensure parent is of the correct type?