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
On Aug 22, 2013, at 3:07 AM, oglop wrote:
> On Wednesday, August 21, 2013 10:56:08 PM UTC+8, oglop wrote:
>> 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
>
> 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
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
--
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 [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.