How to undock tool when using MayaQWidgetDockableMixin

224 views
Skip to first unread message

likage

unread,
Nov 22, 2018, 9:01:15 PM11/22/18
to Python Programming for Autodesk Maya
Hi all,

I am using `MayaQWidgetDockableMixin` and for some reasons when using Maya 2018, some of the signals are not working when the tool is closed.
While I have managed to find a way to resolve this which is by sending the tool to be docked upon first execution. By doing so, whether I closed it while it was docked or when I tear it off and closed the tool, the closed signals will then be called.

This is how I did it by using the `setDockableParameters` argument in the following manner:
self._window.setDockableParameters(
           dockable=True, x=x_pos, y=y_pos, allowedArea='left', area='left'
       )

My question would be - How can I tear off my tool when it is first docked?
I tried doing the following:
# Check if window is docked or not
if not self._window.isFloating():
  """
  Details for `raise_()`:
  Raises the widget to the top.  Will raise the parent widget if it is a QDockWidget.
  Overrides standard QWidget.raise_()
  """
    self._window.raise_()

It does not seems to be tearing off the said tool at all. but instead the tool remains docked.


Appreciate in advance if anyone may have any ideas.

Joe Weidenbach

unread,
Nov 22, 2018, 9:18:24 PM11/22/18
to python_in...@googlegroups.com
Maya2018 went to Qt5, so you might need to read the sources and see what's going on with the docking code.  My supposition is that it's using a QDockableWidget under the hood, but my experience with Maya 2018 and docking custom UI's is very mixed.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/c16baaee-c571-491f-91bb-f2312ac31650%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phil Sloggett

unread,
Nov 22, 2018, 11:08:30 PM11/22/18
to python_in...@googlegroups.com
Agreed, and these days everything is comprised of these “workspaceControls” rather than dockwidgets - I think that mixin class is out of date already.

Personally I use a pretty ugly hack these days where:
- I create a workspaceControl
- grab a handle to it using the MQtUtil findControl method
- and shove my own qt widget in to the child layout of that control.

I’m not sure if this will help with you signal problem, but I suspect it will - its a bit of a “best of both worlds” solution. You can still maintain your pointer to your own widget (without any weird mixin shizzle) and also use the workspaceControl maya.cmds to manage the window state.

likage

unread,
Nov 22, 2018, 11:13:53 PM11/22/18
to Python Programming for Autodesk Maya
Hi all, many thanks for getting me back on this.

I am implementing some new functions in this tools that was previously written by someone, and I would not want to break any of its code if possible as this tool comprises of several scripts.

Even so, is there a way that I can get by with using the mixin class?

@Phil, wondering if you could kindly provide me a simple example for the hack that you mention of?

Reply all
Reply to author
Forward
0 new messages