Hi Aaron,
once again thanks a lot for your advice!
I remember using the IconMode for another reason which I can't remember
now. Your explanation makes sense though.
I didn't use a table view because I didn't know how to set it up so once
cell would display independent items (rather than one item's attributes
being represented by an entire row).
I am more than happy to abandon delegates, I have now realised which
situations they are good for, and my case is certainly not one of those
since I need no editing facilities but interactive controls for each items.
>> - Define the grid of widgets and the widgets in the view, emit
signals for your mouse operations (enter, leave, drag and drop etc.)
how to I assign widgets to a TableView? That's what I was trying all day
yesterday. Or do I have to use a TableWidget?
>>- Handle this signals in the controller and propagate changes to the
model if there are any (e.g. drag and drop changes the order)
there won't ever be any changes. drag&drop is only meant to enable you
to drag items from the view to another widget to collect them (to then
be able to operate them as a collection).
Thanks heaps for the pointers. I very much felt like I was heading into
a dead end.
>> Have a nice evening!
I'm in New Zealand, just starting work now :)
Cheers,
frank
On 3/07/12 1:22 AM, Aaron Richiger wrote:
Hello Frank!
I still think, that delegates are not the best option here... I played
around with the current version of your project and noticed the following:
- Using IconMode for the QListview is not thought for your use of
making a QListView with two columns. IconMode is used if there is a
relation between the first item (icon) and the second item(e.g.
label). A typical example is a FileBrowser, where you have the icon
first and the filename after. Since you have absolutely no connection
between your first and second item, this is the wrong choice. It would
be better to use QTableView in such a case (with the advantage, that
you can easily change your GUI later to display three or four columns
instead of just two, which would not be possible with your solution)
- I still think, that delegates are not the best option for your
purpose. Usually, delegates are for editing the data of the underlying
model, but in your case, you don't want to change the data of the
model, but start an action (e.g. on mouseClick). I think, it would be
easier to implement it without delegates!
I would implement it the following way:
- Define the grid of widgets and the widgets in the view, emit signals
for your mouse operations (enter, leave, drag and drop etc.)
- Handle this signals in the controller and propagate changes to the
model if there are any (e.g. drag and drop changes the order)
Have a nice evening!
Aaron
Am 02.07.2012 08:18, schrieb Frank Rueter | OHUfx:
I'm half a step closer I think:
I'm using the QStyledItemDelegate.createEditor method to assign my
custom widget to the delegate as an editor:
class ToolButtonDelegate( QStyledItemDelegate ):
'''Delegate for ToolView. Might have to use widget instead to get
mouse over effects'''
def __init__( self, parent=None ):
super( ToolButtonDelegate, self).__init__( parent )
self.parent = parent
def createEditor( self, parent, option, index ):
if not index.isValid():
return False
btn = FancyButton( index.data( Qt.UserRole ), parent=parent )
return btn
This draws the "FancyButton" widget when the item is clicked, or
whatever else the View's editTriggers are set to.
Unfortunately there is no "mouseOver" edit trigger which could have
been a feasible workaround.
I am just experimenting with connecting the QAbstractView.entered
signal to the QAbstractView.edit slot but with very limited success.
I get the editor on mouse over for the first item, but it stays open
and I get "edit: editing failed" on all subsequent enter event.
There is no "left" signal to close the editor again when the mouse
cursor leaves the respective item, so I'm not sure if it's possible
to use this approach.
On 2/07/12 5:20 PM, Frank Rueter | OHUfx wrote:
Does anybody have an idea how to do this?
This seems to be turning into a show stopper for me.
I found this thread but since it's C++ I have a hard time
deciphering it:
http://www.qtcentre.org/threads/8660-Drawing-a-widget-in-QItemDelegate-s-paint-method
I don't need to edit the item data, just need to represent it with a
custom widget (showing various buttons inside the widget on mouse
over) and make it drag&dropable.
I've attached a screen grab of what my working custom widget looks
like (with and without mouse over). I hope it comes through ok.
I *just* need to be able to use this as a delegate somehow.
Cheers,
frank
On 25/06/12 3:47 PM, Frank Rueter | OHUfx wrote:
Hi all,
I'm just re-writing part of my existing code to use the mode/view
approach.
I already have a complex custom widget which is a large button that
can
be dragged and dropped, and that shows "sub buttons" on mouse over
(i.e.
smaller rectangles are displayed in the corners on mouse over which
act
as buttons in their own right).
The whole widget works exactly like I want it to, but now I'm
wondering
if it's possible to create a QStyledItemdelegate for the new
model/view
approach to do the same thing. It will need the same event handling as
my custom widget, such as enterEvent, leaveEvent, mouseReleaseEvent,
mousePressEvent, mouseReleaseEvent and mouseMoveEvent.
Is this possible with a delegate? Or can it be achieved in other ways?
Any pointers would be much appreciated.
Cheers,
frank
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside
_______________________________________________
PySide mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/pyside