diff --git a/src/app/qtkmainwindow.cpp b/src/app/qtkmainwindow.cpp index 5a48331..763a33d 100644 --- a/src/app/qtkmainwindow.cpp +++ b/src/app/qtkmainwindow.cpp @@ -25,6 +25,7 @@ MainWindow::MainWindow(QWidget * parent) : QMainWindow(parent) // Initialize static container for all active QtkWidgets auto qtkWidgets = findChildren(); for (auto & qtkWidget : qtkWidgets) { + qtkWidget->setMainWindow(this); // NOTE: Set a temporary scene for the widget to use for initialization. // This should be replaced by loading a scene, or creating a new (unsaved) // scene when Qtk is opened. diff --git a/src/designer-plugins/qtkwidget.cpp b/src/designer-plugins/qtkwidget.cpp index e9e7ad7..e134b56 100644 --- a/src/designer-plugins/qtkwidget.cpp +++ b/src/designer-plugins/qtkwidget.cpp @@ -7,16 +7,14 @@ ##############################################################################*/ #include -#include -#include #include +#include #include "qtk/input.h" #include "qtk/scene.h" #include "qtk/shape.h" #include "debugconsole.h" -#include "app/qtkmainwindow.h" #include "qtkwidget.h" using namespace Qtk; @@ -85,8 +83,10 @@ void QtkWidget::initializeGL() connect(this, SIGNAL(frameSwapped()), this, SLOT(update())); // Add the debug console widget to the window and set its hidden state. - MainWindow::getMainWindow()->addDockWidget( - Qt::DockWidgetArea::BottomDockWidgetArea, mConsole); + if (mMainWindow != nullptr) { + mMainWindow->addDockWidget(Qt::DockWidgetArea::BottomDockWidgetArea, + mConsole); + } mConsole->setHidden(!mConsoleActive); // Initialize OpenGL debug context diff --git a/src/designer-plugins/qtkwidget.h b/src/designer-plugins/qtkwidget.h index 5fb2222..16a250c 100644 --- a/src/designer-plugins/qtkwidget.h +++ b/src/designer-plugins/qtkwidget.h @@ -119,6 +119,11 @@ namespace Qtk */ void setScene(Qtk::Scene * scene); + /** + * @param window The QMainWindow that owns this QtkWidget. + */ + void setMainWindow(QMainWindow * window) { mMainWindow = window; } + /************************************************************************* * Public Members ************************************************************************/ @@ -218,6 +223,7 @@ namespace Qtk Qtk::Scene * mScene; Qtk::DebugConsole * mConsole; bool mConsoleActive = true; + QMainWindow * mMainWindow = Q_NULLPTR; }; /**