View Full Version : C++ API: what are the names of maya windows?
11-23-2010, 05:06 PM
I'm trying to use the MQtUtil::findWindow() function to get the "Uv Texture Editor" QWidget*.
QWidget* window = MQtUtil::findWindow("TextureViewWindow");
QWidget* window = MQtUtil::findWindow("Uv Texture Editor");
Does anyone know how to get a window name?
11-24-2010, 10:03 PM
Try Visual Studio spy++ to find the window name.
11-25-2010, 06:23 AM
You can turn on output all in script editor, then when you open them up it should tell you the name.
11-25-2010, 10:02 AM
tearOffPanel "UV Texture Editor" "polyTexturePlacementPanel" true;
// Result: polyTexturePlacementPanel1Window //
Yeah, that should be it! Thanks
11-26-2010, 10:22 AM
Here's the code to get the window or panel (in case it's docked)
// First look for the panel, it could be docked and is most likely to be found
QWidget* polyTexturePlacementPanel = MQtUtil::findLayout("polyTexturePlacementPanel1");
if (polyTexturePlacementPanel != 0)
// Hmm ok, we've found the panel, maybe we can now find the window
QWidget* polyTextureWindow = MQtUtil::findWindow("polyTexturePlacementPanel1Window");
if (polyTextureWindow != 0)
// Nice, we've found the window so we now know it's not docked
// Meh, for example's sake we'll just close it!
// Hmm the panel doesn't exist, so we can assume the window doesn't exist either
// So by calling this command we ensure it's initialized for the first time
// Now we should find the panel AND window without problems
polyTexturePlacementPanel = MQtUtil::findLayout("polyTexturePlacementPanel1");
polyTextureWindow = MQtUtil::findWindow("polyTexturePlacementPanel1Window");
// Maybe it's safer to check if these were actually found again.
// Maybe now I can close the window as now I have the pointer, and the user did not have that window open yet
11-26-2010, 10:33 AM
There is also a dirty way to find a window, loop through the a huge list of widgets and try and find a matching name.
// This is a dirty way of finding a window, you should use MQtUtil::findWindow instead
// Only do this if you have a good reason to
// Get the maya app
QApplication* mayaApp = dynamic_cast<QApplication*>(QCoreApplication::instance());
// Get the maya QMainWindow
QMainWindow* mainWindow = dynamic_cast<QMainWindow*>(MQtUtil::mainWindow());
// Open up the UvTextureEditor so we can be sure it exists in the app's top-level widgets
// Get all top-level (Windows, tear-off menu's, ..) widgets, and check if the windowTitle matches up
QWidgetList allWidgets = mayaApp->topLevelWidgets();
QWidget* uvTextureEditorWindow = 0;
// We need to iterate over all top level widgets to find a window with the matching name. But I've noticed this is somewhere
// at the beginning, so it only loops +- 25 times
for (int i=0; i<allWidgets.length(); ++i)
QWidget* widget = allWidgets.at(i);
// To see what we're finding...
if (widget->windowTitle() == "UV Texture Editor")
// This is it!
uvTextureEditorWindow = widget;
// Do stuff with that window
if (uvTextureEditorWindow != 0)
// For example: now you can close it again :)
11-26-2010, 10:33 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.