开发者

Using dataChanged() in PySide

I am currently working on a GUI design and would like to add drag/drop functionality between two separate QListViews with their own QStringListModels.

I am able to drag and drop by enabling functionality of the individual views, but am unable to figure out a way for the 'dropping' of an item to trigger an event. I thought it would be done through dataChanged(), which is inherited in QListView, but was having trouble figuring out the QModelIndex and how to use that in dataChanged's arguments.

To further complicate it, One list has items and the other does not; I am trying to drag items from populated list to populate an empty list.

The plan of attack I had was to trigger an event, similar to a LineEdit's textChanged signal and then process the information of the change of the view, and update accordingly.

How do you use dataChanged/QModelIndex? Is there a better way to do this?开发者_如何学Go

Thanks in advance, cheers!


Could you update the post with a bit more information about what you are actually doing in the code?

I think the way it's supposed to work is that you re-implement the dataChanged slot in the QListView. When the item is dropped, dataChanged gets called with the QModelIndex(es) of the item(s) added to the QListView's model, so that you can do whatever processing you want based on the added item(s).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜