Drag and Drop from a Qt Application (in Python)

Official support for: bitwig.com
Post Reply New Topic
RELATED
PRODUCTS

Post

I have written a small app in Qt that generates Midi that you can drag into a DAW. It works with Ableton and Reaper, but not Bitwig. I can dump the midi to a file and drag from Windows explorer, but I'm wondering if anybody here knows why Bitwig may refuse a drag and drop?

The following works with Reaper and Ableton, but not Bitwig. Also I can drag from the app to an explorer window, and from the explorer window into Bitwig, but not directly into Bitwig. (Are there any drag and drop experts here?)

Code: Select all

  def mousePressEvent(self,e):
    if e.button() == Qt.LeftButton:
      drag = QDrag(self)
      with tempfile.NamedTemporaryFile(suffix=".mid",delete=False) as f:
        fn = f.name
        f.write(mid) # mid is the midi data, for now just read from a file known to be valid smf
      temp_filenames.append(fn)
      mimeData = QMimeData()
      mimeData.setData("audio/midi",QByteArray(""))
      urls = [ QUrl.fromLocalFile(fn) ]
      imeData.setUrls(urls)
      drag.setMimeData(mimeData)
      dropAction = drag.exec(Qt.CopyAction)

Post Reply

Return to “Bitwig”