0
こんにちは私はPySideで私のguiにファイル(画像)をドラッグしたいですが、私はそれを動作させることができません。私はそれをdropEvent関数に入れることはできません。私がドラッグしようとしている私のオブジェクトはQGraphicsViewなので、フィルタは2つの画像をドラッグしたいのでgui全体を引き継ぐことはできません。あなたはQtは、後続のドロップイベントを処理する前に、ドラッグイベントを入力して受け入れる必要PySideを使用してguiにファイルをドラッグ
class Consumer(QMainWindow, Ui_MainWindow, QComboBox, QtGui.QWidget):
def __init__(self, parent=None):
self.paylod = None
super(Consumer, self).__init__(parent)
self.setupUi(self)
self.chkApplyCompression.stateChanged.connect(self.makecompress)
self.viewCarrier1.setMouseTracking(True)
self.viewCarrier1.installEventFilter(self)
layout = QtGui.QVBoxLayout(self)
layout.addWidget(self.viewCarrier1)
def eventFilter(self, source, event):
if (event.type() == QtCore.QEvent.QDropEvent and
print('yay?')
return QtGui.QWidget.eventFilter(self, source, event)
def dropEvent(self, e):
print("yay")
def dragEnterEvent(self, *args, **kwargs):
print("Yay!!")
if __name__ == "__main__":
currentApp = QtGui.QApplication(sys.argv)
currentForm = Consumer()
currentForm.show()
currentApp.exec_()
おかげ