Quick follow up (as usual):
The problem is that the view's mouseMoveEvent fires faster than the
MyMovie() widget's leaveEvent can trigger the emission of the
closeEditor signal.
In other words I have to somehow refactor the code to ensure that the
current editor is closed before the new one is opened.
On 12/08/16 2:12 PM, Frank Rueter | OHUfx wrote:
So I made some progress here:
I am now using the QListView's mouseMoveEvent() to get the item under
the mouse and edit() it:
def mouseMoveEvent(self, event):
'''Find item under mouse and pop it into edit mode'''
index = self.indexAt(event.pos())
if index.isValid():
self.edit(index)
super(ElementView, self).mouseMoveEvent(event)
In my Delegate's createEditor() method I have this:
def createEditor(self, parent, option, index):
proxyModel = index.model()
item =
proxyModel.sourceModel().itemFromIndex(proxyModel.mapToSource(index))
currentEditor = *MyMovie*(item, parent=parent)
currentEditor.*mouseLeftWidget*.connect(self.emitCloseEditorSignal)
return currentEditor
The *MyMovie() *class has a leaveEvent that emits the
*mouseLeftWidget* signal.
The above works and the various instances of MyMovie() play back on
mouse over inside my QWLIstView and stop when the mouse leaves them,
but for some reason I still get "edit: editing failed" messages when I
move the mouse around quickly.
I don't get those messages when I move the mouse slowly though, which
is interesting.
Does anybody have an idea why that would be?
Cheers,
frank
On 9/08/16 5:50 PM, Frank Rueter | OHUfx wrote:
And one more follow up:
I just tried this in my view class:
def mouseMoveEvent(self, event):
'''Find item under mouse and pop it into edit mode'''
index = self.indexAt(event.pos())
self.edit(index)
This successfully pops the first item under the mouse into edit mode,
but as I keep moving the cursor around I just get:
edit: editing failed
This one stumped me yesterday as well when I tried to use the
Delegate's paint method to trigger it's editor on mouse over.
Does anybody have any ideas how to start editing on mouse over with
delegates and list views?
Cheers,
frank
On 9/08/16 5:27 pm, Frank Rueter | OHUfx wrote:
Ok, so after some more experimenting I am fairly certain that using
seItemWidget inside the delegate's paint event is a bad idea.
My second approach seems more promising so far: Using the custom
movie player widget as the delegate's editor, even though I don't
actually want to edit anything.
However, since I need the movie player to start playing on mouse
over, I need to work out how to pop the item under the mouse into
edit() mode (and finish editing when the mouse leaves the item).
After googling a bit it seems a few others have tried this but to no
avail.
Any ideas on that one?
Cheers,
frank
On 8/08/16 4:28 pm, Frank Rueter | OHUfx wrote:
Hi Bo,
I have followed your advise and gone back to QListView with a delegate.
My first test was to render the custom widget I need via the
delegate paint method. This populates a static version of the movie
player (the custom widget I need).
Then, also in the delegate's paint method, I use setItemWidget if
the mouse hovers over the item, to get the fully fledged and
interactive widget.
This seems to be promising but it kinda feels wrong to set an item
widget in the paint method. Should I worry?
Also, I can't get the rendered image to line up with the item
widget itself. The render seems to have the correct size but the
widget, when the mouse hovers over the item, is slightly off,
causing the item to pop a little and leave out-of-date paint
artifacts when the mouse leaves again.
Below is my test code for the delegate.
Now I am wondering if the below approach is acceptable (setting an
item widget inside the delegate's paint event).
Alternatively I'm wondering if I could/should use the delegate's
createEditor method to display the widgets of all visible items to
achieve the same thing (which is full interactive and animated
widget in all visible items). I have, however, not been able to
figure out how to call the editor on mouse enter, which I need
because the movie is supposed to play when the mouse hovers over it.
Any opinions on this?
Cheers,
frank
class DelegateOld(QtGui.QItemDelegate):
def __init__(self, parent = None):
super(Delegate, self).__init__(parent)
self.thumbnail = None
def paint(self, painter, option, index):
item = index.model().itemFromIndex(index)
self.thumbnail = MyMovie(item)
if option.state & QtGui.QStyle.State_MouseOver:
# swap render for actual widget here. So the user can
interact with it - doesn't feel right though to do this in the
paint event
existingThumb = self.view.indexWidget(index)
if not existingThumb:
self.view.setIndexWidget(index, self.thumbnail)
else:
self.thumbnail.render(painter,
QtCore.QPoint(option.rect.x(), option.rect.y()))
def sizeHint(self, option, index):
return MyMovie.thumbSize
On 4/08/16 8:36 pm, Bo Thorsen wrote:
Den 04-08-2016 kl. 10:05 skrev Frank Rueter | OHUfx:
I am playing with the idea of writing a custom widget based on
QScrollArea, where widgets are created as the user scrolls.
I'm just hoping to bounce the general idea of you guys here to
see if
I'm heading in the right direction:
I have a heap of custom widgets, potentially thousands, depending
on the
contents of a database.
I'd like to show them in a grid that fits as many widgets
horizontally
as will fit in the current window size (dynamic).
I would also like smooth vertical scrolling.
If I create a single parent widget with a grid layout that
creates all
widgets on start up, it takes ages.
So I'm thinking if I use the child widgets' visibleRegion() to
find the
ones currently visible in the scroll area, then figure out the
indexes
of the widgets in the rows above and below to create them
dynamically,
that should speed up the startup and still provide smooth scrolling.
Obviously I'd have to manually scale the scroll area based on the
maximum amount of widgets and the parent widget's width to get an
indicative scrollbar.
Not sure how tricky that will be.
Does that sound crazy or doable?
Basically I am trying to re-create the behavior of a QListView in
icon
mode. I tried using QListView with delegates, but couldn't get the
delegates to provide the kind of complexity I need for the child
widgets
which I have already written (which are basically mini movie players
that can be drag&dropped and have playback all at once on demand).
Any thoughts on this before I dive into this little experiment?
I don't think that sounds unreasonable. If I were you, I would try
very hard to stay with QListView instead, but other than that it
doesn't sound hard to do. Time consuming, yes, but not difficult.
Bo Thorsen,
Director, Viking Software.
--
ohufxLogo 50x50 <http://www.ohufx.com>
*vfx for storytellers <http://www.ohufx.com>*
*vfx compositing <http://ohufx.com/index.php/vfx-compositing> |
*workflow customisation & consulting
<http://ohufx.com/index.php/vfx-customising>**
*W E L L I N G T O N | N E W Z E A L A N D *
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
--
ohufxLogo 50x50 <http://www.ohufx.com>
*vfx for storytellers <http://www.ohufx.com>*
*vfx compositing <http://ohufx.com/index.php/vfx-compositing> |
*workflow customisation & consulting
<http://ohufx.com/index.php/vfx-customising>**
*W E L L I N G T O N | N E W Z E A L A N D *
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
--
ohufxLogo 50x50 <http://www.ohufx.com>
*vfx for storytellers <http://www.ohufx.com>*
*vfx compositing <http://ohufx.com/index.php/vfx-compositing> |
*workflow customisation & consulting
<http://ohufx.com/index.php/vfx-customising>**
*W E L L I N G T O N | N E W Z E A L A N D *
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest