Discussion:
[PySide] manually closing editor on custom delegate
Frank Rueter | OHUfx
2018-05-02 06:32:15 UTC
Permalink
Hi all,

I think I need some MVC help once again:

I am using a custom item delegate that uses the bottom 20 pixels of a
cell in a table view for a QComboBox (the rest will be static content).
I can create the editor in the right spot etc, but I can't figure out
how to close it again when the user clicks into the upper part of the cell.
I tried all sorts of events and signals in the view, the delegate and
the editor itself but to no avail.
This is the state of things:

The initial table:


The table with the open editor after clicking into the bottom 20 pixels
of a cell:


The table after I click away from the editor but into the same cell, in
which case I'd like to close it and show the initial state as seen
above, but I just can't figure out how to.


Attached is the working code to produce the above images.

Any help would be greatly appreciated!

Cheers,
frank
--
ohufxLogo 50x50 <http://www.ohufx.com>
*vfx compositing <http://ohufx.com/compositing.html> | *workflow
customisation and consulting <http://ohufx.com/customising.html>* *
*<http://ohufx.com/compositing.html>*
<http://www.nukepedia.com/nubridge>


Your gateway to over 1,000 free tools... right inside of Nuke
<http://www.nukepedia.com/nubridge>
Frank Rueter | OHUfx
2018-05-02 21:34:49 UTC
Permalink
anyone?
Post by Frank Rueter | OHUfx
Hi all,
I am using a custom item delegate that uses the bottom 20 pixels of a
cell in a table view for a QComboBox (the rest will be static content).
I can create the editor in the right spot etc, but I can't figure out
how to close it again when the user clicks into the upper part of the cell.
I tried all sorts of events and signals in the view, the delegate and
the editor itself but to no avail.
The table with the open editor after clicking into the bottom 20
The table after I click away from the editor but into the same cell,
in which case I'd like to close it and show the initial state as seen
above, but I just can't figure out how to.
Attached is the working code to produce the above images.
Any help would be greatly appreciated!
Cheers,
frank
--
ohufxLogo 50x50 <http://www.ohufx.com>
*vfx compositing <http://ohufx.com/compositing.html> | *workflow
customisation and consulting <http://ohufx.com/customising.html>* *
*<http://ohufx.com/compositing.html>*
<http://www.nukepedia.com/nubridge>
Your gateway to over 1,000 free tools... right inside of Nuke
<http://www.nukepedia.com/nubridge>
_______________________________________________
PySide mailing list
http://lists.qt-project.org/mailman/listinfo/pyside
Frank Rueter | OHUfx
2018-05-03 21:09:18 UTC
Permalink
Thanks Matthieu, much appreciated!
That seems so obvious now that I see it :-D

I have to admit that I am now considering using the context menu and
customising that, since it already displays the behaviour I am after
(single click to open and close when you click off).

Good to have both options though, so thanks again!

Cheers,
frank
Oups forgot the markdown highlight :P
|else: # Can't get this to work. I want to close the editor here
(without committing any data). print "\tclicked off - I want to close
teh editor now if it's open"
self.closeEditor(self.itemDelegate().current_editor,
QtWidgets.QAbstractItemDelegate.NoHint) |
|def createEditor(self, parent, option, index): '''Creates a combo box
to chose the version to sync in case tehre are mote than one used in a
sequence. Only show the editor if the mouse click ocurrs in the area
where the editor lives. ''' self.current_editor =
QtWidgets.QComboBox(parent)
self.current_editor.setMaximumHeight(self.editorHeight) return
self.current_editor |
​
On Thu, May 3, 2018 at 10:09 AM, Matthieu Cadet
```python
            # Can't get this to work. I want to close the editor
here (without committing any data).
            print "\tclicked off - I want to close teh editor now
if it's open"
            self.closeEditor(self.itemDelegate().current_editor,
                             QtWidgets.QAbstractItemDelegate.NoHint)
```
```python
        '''Creates a combo box to chose the version to sync in
case tehre are mote than one used in a sequence.
        Only show the editor if the mouse click ocurrs in the area
where the editor lives.
        '''
        self.current_editor = QtWidgets.QComboBox(parent)
        self.current_editor.setMaximumHeight(self.editorHeight)
        return self.current_editor
```
On Thu, May 3, 2018 at 10:06 AM, Matthieu Cadet
Ah ok I miss read your problem... I got the same behaviour if
I click the Edit zone and then click again the edit zone on
the same Cell,
clicking outside of the edited cell close the Editor.
On Thu, May 3, 2018 at 9:59 AM, Matthieu Cadet
Hi Frank!
I've tried your sample code and I don't see this behaviour
on Linux Centos, I can click to open the editor, choose an
item inside
then when I click outside of it, it close normally.
Maybe try to remove the line `editor.showPopup()` in the
`def setEditorData(self, editor, index):`
as you call
```
            # Click was inside of editor area so open it
for the index
self.setCurrentIndex(index)
            self.edit(index)
```
you don't have to .showPopup() normally... or maybe it is
macos bug :P
On Wed, May 2, 2018 at 11:34 PM, Frank Rueter | OHUfx
anyone?
Post by Frank Rueter | OHUfx
Hi all,
I am using a custom item delegate that uses the
bottom 20 pixels of a cell in a table view for a
QComboBox (the rest will be static content).
I can create the editor in the right spot etc, but I
can't figure out how to close it again when the user
clicks into the upper part of the cell.
I tried all sorts of events and signals in the view,
the delegate and the editor itself but to no avail.
The table with the open editor after clicking into
The table after I click away from the editor but into
the same cell, in which case I'd like to close it and
show the initial state as seen above, but I just
can't figure out how to.
Attached is the working code to produce the above images.
Any help would be greatly appreciated!
Cheers,
frank
--
ohufxLogo 50x50 <http://www.ohufx.com>
*vfx compositing <http://ohufx.com/compositing.html>
| *workflow customisation and consulting
<http://ohufx.com/customising.html>* *
*<http://ohufx.com/compositing.html>*
<http://www.nukepedia.com/nubridge>
Your gateway to over 1,000 free tools... right inside
of Nuke <http://www.nukepedia.com/nubridge>
_______________________________________________
PySide mailing list
http://lists.qt-project.org/mailman/listinfo/pyside
<http://lists.qt-project.org/mailman/listinfo/pyside>
_______________________________________________
PySide mailing list
http://lists.qt-project.org/mailman/listinfo/pyside
<http://lists.qt-project.org/mailman/listinfo/pyside>
--
Matthieu Cadet
Compositor Artist & TD,
nWave Digital
--
Matthieu Cadet
Compositor Artist & TD,
nWave Digital
--
Matthieu Cadet
Compositor Artist & TD,
nWave Digital
--
Matthieu Cadet
Compositor Artist & TD,
nWave Digital
Cristián Maureira-Fredes
2018-05-03 12:43:36 UTC
Permalink
Hello Frank,

I'm a little bit confused,
is the attached GIF the expected behavior?
of you would like to display the selected number inside the green area
where the QComboBox is located?

Cheers

________________________________________
From: PySide <pyside-bounces+cristian.maureira-fredes=***@qt-project.org> on behalf of Frank Rueter | OHUfx <***@ohufx.com>
Sent: 02 May 2018 08:32:15
To: ***@qt-project.org
Subject: [PySide] manually closing editor on custom delegate

Hi all,

I think I need some MVC help once again:

I am using a custom item delegate that uses the bottom 20 pixels of a cell in a table view for a QComboBox (the rest will be static content).
I can create the editor in the right spot etc, but I can't figure out how to close it again when the user clicks into the upper part of the cell.
I tried all sorts of events and signals in the view, the delegate and the editor itself but to no avail.
This is the state of things:

The initial table:
[cid:***@ohufx.com]

The table with the open editor after clicking into the bottom 20 pixels of a cell:
[cid:***@ohufx.com]

The table after I click away from the editor but into the same cell, in which case I'd like to close it and show the initial state as seen above, but I just can't figure out how to.
[cid:***@ohufx.com]

Attached is the working code to produce the above images.

Any help would be greatly appreciated!

Cheers,
frank


--

[ohufxLogo 50x50]<http://www.ohufx.com>
vfx compositing<http://ohufx.com/compositing.html> | workflow customisation and consulting<http://ohufx.com/customising.html>
<http://ohufx.com/compositing.html>

[Loading Image...] <http://www.nukepedia.com/nubridge>


Your gateway to over 1,000 free tools... right inside of Nuke<http://www.nukepedia.com/nubridge>
Frank Rueter | OHUfx
2018-05-03 21:11:31 UTC
Permalink
Hi Christian,

thanks for taking a look.
The behaviour in the gif is the expected one, but it won't happen if you
click in the white are of the same cell.

The context menu actually behaves exactly like I want, so I am looking
into customising that which should simplify the code as well.

Cheers,
frank
Post by Cristián Maureira-Fredes
Hello Frank,
I'm a little bit confused,
is the attached GIF the expected behavior?
of you would like to display the selected number inside the green area
where the QComboBox is located?
Cheers
________________________________________
Sent: 02 May 2018 08:32:15
Subject: [PySide] manually closing editor on custom delegate
Hi all,
I am using a custom item delegate that uses the bottom 20 pixels of a cell in a table view for a QComboBox (the rest will be static content).
I can create the editor in the right spot etc, but I can't figure out how to close it again when the user clicks into the upper part of the cell.
I tried all sorts of events and signals in the view, the delegate and the editor itself but to no avail.
The table after I click away from the editor but into the same cell, in which case I'd like to close it and show the initial state as seen above, but I just can't figure out how to.
Attached is the working code to produce the above images.
Any help would be greatly appreciated!
Cheers,
frank
--
[ohufxLogo 50x50]<http://www.ohufx.com>
vfx compositing<http://ohufx.com/compositing.html> | workflow customisation and consulting<http://ohufx.com/customising.html>
<http://ohufx.com/compositing.html>
[http://nukepedia.com/images/nuBridge/logo/nuBridge_logo.png] <http://www.nukepedia.com/nubridge>
Your gateway to over 1,000 free tools... right inside of Nuke<http://www.nukepedia.com/nubridge>
Loading...