本文整理汇总了Python中PyQt4.QtCore.QMimeData类的典型用法代码示例。如果您正苦于以下问题:Python QMimeData类的具体用法?Python QMimeData怎么用?Python QMimeData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMimeData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _newListDropEvent
def _newListDropEvent(self, event):
if event.provides('mpd/uri'):
event.accept()
parent = self._newList()
data = QMimeData()
data.setData('mpd/uri', event.mimeData().data('mpd/uri'))
def disconnect(item, row=-1, column=-1):
if parent.row() == row:
self.disconnect(self.playlistList.itemDelegate(parent),
SIGNAL('commitData(QWidget *)'),
addSongs)
self.disconnect(self.playlistModel,
SIGNAL('rowsAboutToBeRemoved(const QModelIndex &, int , int)'),
disconnect)
def addSongs(editor, data=data):
# Make sure to disconnect from the signals.
if parent.data(Qt.DisplayRole):
disconnect(None, parent.row())
self.playlistModel.dropMimeData(data, Qt.CopyAction, 0, 0, parent)
self.connect(self.playlistList.itemDelegate(parent),
SIGNAL('commitData(QWidget *)'),
addSongs)
self.connect(self.playlistModel,
SIGNAL('rowsAboutToBeRemoved(const QModelIndex &, int , int)'),
disconnect)
示例2: eventFilter
def eventFilter( self, object, event ):
if event.type() == event.MouseButtonPress:
if self.isLocked():
return False
if event.button() == Qt.MidButton or \
(event.button() == Qt.LeftButton and \
event.modifiers() == Qt.ShiftModifier):
index = self.tabBar().tabAt(event.pos())
view = self.widget(index)
pixmap = QPixmap.grabWidget(view)
drag = QDrag(self)
data = QMimeData()
data.setText('move view:{}'.format(index))
drag.setMimeData(data)
drag.setPixmap(pixmap)
drag.exec_()
return True
return False
elif event.type() == event.DragEnter:
if ( str(event.mimeData().text()).startswith('move view:') and
event.source() != self ):
event.acceptProposedAction()
return True
elif event.type() == event.Drop:
text = str(event.mimeData().text())
splt = text.split(':')
self.snagViewFromPanel(event.source(), int(splt[1]))
return True
return False
示例3: mimeData
def mimeData(self, indexes):
nodes = dedupe(index.internalPointer() for index in indexes)
paths = [str(self.name + node.ref.path) for node in nodes]
data = '\n'.join(paths).encode('utf-8')
mimeData = QMimeData()
mimeData.setData(MIME_PATHS, QByteArray(data))
return mimeData
示例4: startDrag
def startDrag(self, dropActions):
"""Reimplement Qt Method - handle drag event"""
mimeData = QMimeData()
mimeData.setText(self.get_filename())
drag = QDrag(self)
drag.setMimeData(mimeData)
drag.exec_()
示例5: startDrag
def startDrag(self, dropActions):
"""Reimplement Qt Method - handle drag event"""
data = QMimeData()
data.setUrls([QUrl(fname) for fname in self.get_selected_filenames()])
drag = QDrag(self)
drag.setMimeData(data)
drag.exec_()
示例6: __onDragStarted
def __onDragStarted(self, index):
desc = index.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
icon = index.data(Qt.DecorationRole)
drag_data = QMimeData()
drag_data.setData(
"application/vnv.orange-canvas.registry.qualified-name",
desc.qualified_name
)
drag = QDrag(self)
drag.setPixmap(icon.pixmap(38))
drag.setMimeData(drag_data)
# TODO: Should animate (accept) hide.
self.hide()
# When a drag is started and the menu hidden the item's tool tip
# can still show for a short time UNDER the cursor preventing a
# drop.
viewport = self.__menu.view().viewport()
filter = ToolTipEventFilter()
viewport.installEventFilter(filter)
drag.exec_(Qt.CopyAction)
viewport.removeEventFilter(filter)
示例7: copy
def copy(self):
"""Copy to the clipboard"""
data = QMimeData()
text = "\n".join([cursor.selectedText() for cursor in self.cursors()])
data.setText(text)
data.setData(self.MIME_TYPE, text.encode("utf8"))
QApplication.clipboard().setMimeData(data)
示例8: mimeData
def mimeData(self, indexes):
items = (index.internalPointer() for index in indexes if index.isValid())
uri_list = self._getURIs(items)
uri_list.sort()
data = QMimeData()
data.setData('mpd/uri', pickle.dumps(uri_list))
return data
示例9: mousePressEvent
def mousePressEvent( self, event ):
# handle an internal move
from PyQt4.QtCore import Qt
# start a drag event
if ( event.button() == Qt.LeftButton and self.dragDropRect().contains( event.pos() ) ):
from PyQt4.QtCore import QMimeData
from PyQt4.QtGui import QDrag, QPixmap
# create the pixmap
pixmap = QPixmap.grabWidget( self, self.rect() )
# create the mimedata
mimeData = QMimeData()
mimeData.setText( 'ItemTitle::%s' % (self.title()) )
# create the drag
drag = QDrag(self)
drag.setMimeData( mimeData )
drag.setPixmap( pixmap )
drag.setHotSpot( event.pos() )
if ( not drag.exec_() ):
self._accordianWidget.emitItemDragFailed(self)
event.accept()
# determine if the expand/collapse should occur
elif ( event.button() == Qt.LeftButton and self.expandCollapseRect().contains( event.pos() ) ):
self._clicked = True
event.accept()
else:
event.ignore()
示例10: mimeData
def mimeData(self, indexes ):
"""See QAbstractItemModel documentation"""
if len(indexes) != 1:
return 0
data = QMimeData()
data.setData( self.mimeTypes()[0], QByteArray.number( indexes[0].row() ) )
return data
示例11: _copy
def _copy(self, index):
doc = QTextDocument()
doc.setHtml(index.data(Qt.DisplayRole).toString())
clipboard = QApplication.clipboard()
richTextData = QMimeData()
richTextData.setHtml(index.data(Qt.DisplayRole).toString())
richTextData.setText(doc.toPlainText())
clipboard.setMimeData(richTextData)
示例12: mimeData
def mimeData(self, indexes):
if len(indexes) == 1:
item = indexes[0].internalPointer()
d = QMimeData()
d.setData(variable.MIME_TYPE, item.uniqueName)
return d
else:
return None
示例13: startDrag
def startDrag(self, dropAction):
# create mime data object
mime = QMimeData()
mime.setData('text/xml', '???')
# start drag
drag = QDrag(self)
drag.setMimeData(mime)
drag.start(Qt.CopyAction | Qt.CopyAction)
示例14: mimeData
def mimeData(self, indexes):
sortedIndexes = sorted([index for index in indexes
if index.isValid()], key=lambda index: index.row())
encodedData = '\n'.join(self.data(index, Qt.DisplayRole)
for index in sortedIndexes)
mimeData = QMimeData()
mimeData.setData(self.Mimetype, encodedData)
return mimeData
示例15: startDrag
def startDrag(self,event):
drag = QDrag(event.widget())
mimedata = QMimeData()
liste = []
liste.append(QUrl( "veromix://source_output_index:"+str(int(self.index)) ))
mimedata.setUrls(liste)
drag.setMimeData(mimedata)
#drag.setHotSpot(event.pos() - self.rect().topLeft())
dropAction = drag.start(Qt.MoveAction)