I'm attempting to get my code to work with multiple listViews instead of just one but am having an issue.
Working Code for one list:
Class Ui_MainWindow(QtGui.QMainWindow):
def itemDropped(self, links):
item = QtGui.QListWidgetItem(url, self.listView)
def setupUi(self, MainWindow):
self.connect(self.listView, QtCore.SIGNAL("dropped"), self.itemDropped)
Class TestListView(QtGui.QListWidget):
def dropEvent(self, event):
self.emit(QtCore.SIGNAL("dropped"), links)
What I have so far to use multiple lists:
Class Ui_MainWindow(QtGui.QMainWindow):
def itemDropped(self, links, listName):
item = QtGui.QListWidgetItem(url, listName)
def setupUi(self, MainWindow):
self.connect(self.listView, QtCore.SIGNAL("dropped"), self.itemDropped(self.listView))
Class TestListView(QtGui.QListWidget):
def dropEvent(self, event):
self.emit(QtCore.SIGNAL("dropped"), links)
So I get an error with "self.itemDropped(self.listView)" and after research on here and other sites I came up with this:
self.connect(self.listView, QtCore.SIGNAL("dropped"),(lambda : self.itemDropped(self.listView)))
I had never used the lambda function before because I am quite new to python but that did fix the issue, when i print listName it shows up correctly. The problem now is that the links aren't emitting correctly from the other class, or rather I'm not receiving them correctly.
So I guess pseduocode i need something like this:
self.connect(self.listView, QtCore.SIGNAL("dropped"),(lambda : self.itemDropped(X, self.listView)))
The question is how do I get X, that is the links from the TestListView class? I don't quite understand how I was receiving them with just 1 list when there were no variables being passed to the function.
Thanks for any help you guys can provide i greatly appreciate it. P.s. Code from here might look familiar if you want a bigger picture PyQT4: Drag and drop files into QListWidget