Hello all,

So I am having a bit of trouble with a part of my project, basically I have 
a QTableView showing data for the users files and a QTreeView showing the 
file structure.

The app allows you to move files around inside the QTreeView and I need to 
allow the user to also drag files from the TableView into a location in the 
TreeView also.

During the drag operation on each view I set custom mime data to indicate a 
tree item is dragged or a table item is dragged so I know which is which.

During the drag operation in the tree, the default behaviour gives a nice 
little box around each item as you hover over them and also a line 
inbetween. I would like to replicate this behaviour when you drag table 
items over to the treeview.

I have managed to do something similar using a QTreeWidget by using the 
*"setCurrentItem(item)"* on the item you are hovering over which is kinda 
close. Note that I cant use setCurrentIndex in QTreeView because I need the 
indices not to be selected as you are dragging around.

Finding out which index you are hovering over in the QTreeView is not a 
problem, what I cant figure out is how to put the little highlight box 
around the index as you hover over them. I read a bit on overriding the 
paint events but I have never dived into these events before so any help 
would be appreciated.

*QTreeWidget example drag move event:*
def dragMoveEvent(self, event):
    item = self.itemAt(event.pos())
    if item:
        self.setCurrentItem(item)
    else:
        self.clearSelection()
    event.accept()

*QTreeView example drag move event:*
def dragMoveEvent(self, event):
    mime = event.mimeData()
    if mime.hasFormat(cfg.mime_dbview_data):
        item_idx = self.indexAt(event.pos())
    if item_idx:
        self.setCurrentIndex(item_idx)
    else:
        self.clearSelection()
        event.accept()
        return
    super(Tree_Browser_View, self).dragMoveEvent(event)
    event.accept()

// Ben


-- 
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_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/c7afb382-9ad8-43fd-a88a-df691e54877dn%40googlegroups.com.

Reply via email to