why qslider disappears as soon as i drag it in maya ?

37 views
Skip to first unread message

oglop

unread,
Aug 21, 2013, 10:56:08 AM8/21/13
to python_in...@googlegroups.com
i asked this question a while ago on stackoverflow, but nobody answered it.
http://stackoverflow.com/questions/14747112/why-qslider-disappears-as-soon-as-i-drag-it-in-autodesk-maya

yes i know the code is not 100% correct. so i tried to make it more complete like this, i tried it in maya 2014 with pyside, but still as soon as click on the slider, it disappears, am i doing something wrong here ? thanks!
Here is the modified code, i tried adding setData() in the model, and give them correct parent in main window __init__(), but still it doesn't work.

it works fine outside of maya. uncomment the qapplication lines, it runs without any problem.

http://pastebin.com/d1NbarUz

oglop

unread,
Aug 21, 2013, 11:07:03 AM8/21/13
to python_in...@googlegroups.com

i tried this too, from nathan's website:
give my window a parent of main maya window, but it still doesn't work:
http://pastebin.com/Y5F7nMEe

Justin Israel

unread,
Aug 22, 2013, 5:23:45 AM8/22/13
to python_in...@googlegroups.com
The problem seems to be specifically with using a QSlider as an editor, as opposed to something like a QSpinBox, because of the way the events are handled for that kind of widget. The focus events are being mishandled, which makes the widget hide when you click on it.

A solution would be to implement an eventFilter and correct the handling to suit our needs. First you can make the FocusOut event not get handled in the default manner. With this alone, you would be able to use the slider, and then click to another cell to end the editor.
If you want to extend the behavior, you could have it close simply by leaving the cell.


class ShipDelegate(QItemDelegate):

...

def eventFilter(self, obj, event):
typ = event.type()

# Don't let the delegate handle the FocusOut
# causing a click to hide the slider
if typ == event.FocusOut:
return False

# Optionally allow a mouse leave event to hide
# the slider editor. Otherwise you must click
# another cell.
elif typ == event.Leave:
self.closeEditor.emit(obj, self.NoHint)

return super(ShipDelegate, self).eventFilter(obj, event)

...

That should give you something functional. Also, you can probably remove the blocking of the signals. I am not sure they are needed.

-- justin
> --
> 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 post to this group, send email to python_in...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

johnvdz

unread,
Aug 23, 2013, 8:01:32 PM8/23/13
to python_in...@googlegroups.com
hi all,

i'm trying to monitor user deletions. using
OpenMaya.MNodeMessage.addNodeAboutToDeleteCallback()

I'm trying to protect afew nodes from deletion, if somthing down the
line in a chain is selected for deletion.

problem is because maya deletes from child to selected node i can never
get to say unparent the children so they dont delete. and then allow
maya to run its course and delete only selected nodes.

is there a way of muting or destorying a deletion callback before it
happens? it seems maya is commited once cmds.delete() or "doDelete;" is
called. even if i say try to lockNode or anything like that.

i though i might be able to use
OpenMaya.MCommandMessage.addCommandCallback("delete", myfunction()) but
it seems to bug out for me. so i cant test this option. just get alot of
warning. anyone used this option before.

i want to try some changes befor maya commits to deleting nodes.
not sure what my option might be here. can i perhaps undo on say a
MDGModifier or something?

i guess the only other option which id rather not do it to overwrite the
"doDelete;" mel function but then that dosent account for cmds.delete().

anyway insights would be great.


john
Reply all
Reply to author
Forward
0 new messages