Notifications
Clear all
[Closed] C++ QT Window
Feb 18, 2022 12:36 am
I just tried to create a QT window inside Max. This code works just fine:
#include <QtWidgets/QWidget>
#include <maxscript/maxscript.h>
#include <maxscript/macros/define_instantiation_functions.h>
QWidget window;
def_visible_primitive(TestFunction, "TestFunction");
Value* TestFunction_cf(Value **arg_list, int count)
{
window.show();
return NULL;
}
Any idea how we can set parent of this Widget to the Max main window?
3 Replies
Feb 18, 2022 12:36 am
#include <Qt/QmaxMainWindow.h>
MaxSDK::QmaxMainWindow* maxMain = GetCOREInterface()->GetQmaxMainWindow();
window.setParent(maxMain);
Feb 18, 2022 12:36 am
Thank you, but the window will disappear when I set it’s parent. I’m looking for something like we do for the WPF window:
(dotnetobject "System.Windows.Interop.WindowInteropHelper" Window).owner = dotnetobject "IntPtr" (windows.getMAXHWND())
Feb 18, 2022 12:36 am
I find another method which is even more functional:
#include <maxscript/maxscript.h>
#include <maxscript/macros/define_instantiation_functions.h>
#include <Qt/QmaxMainWindow.h>
#include <Qt/QmaxDockWidget.h>
def_visible_primitive(TestFunction, "TestFunction");
Value* TestFunction_cf(Value **arg_list, int count)
{
MaxSDK::QmaxMainWindow* maxMainWindow = GetCOREInterface()->GetQmaxMainWindow();
QDockWidget* dockWidget = new QDockWidget(maxMainWindow);
maxMainWindow->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
dockWidget->setFloating(true);
return NULL;
}