当前位置: 首页>>代码示例>>Python>>正文


Python QDrag.setMimeData方法代码示例

本文整理汇总了Python中PyQt4.QtGui.QDrag.setMimeData方法的典型用法代码示例。如果您正苦于以下问题:Python QDrag.setMimeData方法的具体用法?Python QDrag.setMimeData怎么用?Python QDrag.setMimeData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PyQt4.QtGui.QDrag的用法示例。


在下文中一共展示了QDrag.setMimeData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 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_()
开发者ID:koll00,项目名称:Gui_SM,代码行数:9,代码来源:explorer.py

示例2: eventFilter

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 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
开发者ID:satishgoda,项目名称:DPS_PIPELINE,代码行数:36,代码来源:xviewpanel.py

示例3: mousePressEvent

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
	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()
开发者ID:skarone,项目名称:PipeL,代码行数:36,代码来源:collapsable_groupbox.py

示例4: __onDragStarted

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
    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)
开发者ID:CHANAYA,项目名称:orange3,代码行数:28,代码来源:canvastooldock.py

示例5: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 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_()
开发者ID:Brainsciences,项目名称:luminoso,代码行数:9,代码来源:explorer.py

示例6: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 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)
开发者ID:dreadpiratepj,项目名称:Sabel,代码行数:10,代码来源:tree.py

示例7: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 def startDrag(self, supportedActions):
     drag = QDrag(self)
     mimeData = self.model().mimeData(self.selectedIndexes())
     # mimeData.setText(str(t))
     drag.setMimeData(mimeData)
     if drag.start(Qt.MoveAction) == Qt.MoveAction:
         for item in self.selectedItems():
             self.takeItem(self.row(item))
开发者ID:gkudos,项目名称:qgis-cartodb,代码行数:10,代码来源:ListWidgets.py

示例8: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 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)
开发者ID:florianjacob,项目名称:veromix-plasmoid,代码行数:11,代码来源:SourceOutputUI.py

示例9: mouseMoveEvent

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 def mouseMoveEvent(self, event):
     if event.buttons() != Qt.RightButton:
         return
     mimeData = QMimeData()
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(event.pos() - self.rect().topLeft())
     dropAction = drag.start(Qt.MoveAction)
     if dropAction == Qt.MoveAction:
         self.close()
开发者ID:calpe20,项目名称:PYTHONIZANDO,代码行数:12,代码来源:tab_central_widget.py

示例10: dragFile

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
def dragFile(widget, filename, icon=None, dropactions=Qt.CopyAction):
    """Starts dragging the given local file from the widget."""
    if icon is None or icon.isNull():
        icon = QFileIconProvider().icon(QFileInfo(filename))
    drag = QDrag(widget)
    data = QMimeData()
    data.setUrls([QUrl.fromLocalFile(filename)])
    drag.setMimeData(data)
    drag.setPixmap(icon.pixmap(32))
    drag.exec_(dropactions)
开发者ID:EdwardBetts,项目名称:frescobaldi,代码行数:12,代码来源:drag.py

示例11: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 def startDrag(self,event):
     drag = QDrag(event.widget())
     drag.setPixmap(self.mute.icon().pixmap(self.size().height(),self.size().height()))
     mimedata = QMimeData()
     liste = []
     liste.append(QUrl( "veromix://sink_index:"+str(int(self.index)) ))
     mimedata.setUrls(liste)
     drag.setMimeData(mimedata)
     #drag.setHotSpot(event.pos() - self.rect().topLeft())
     dropAction = drag.start(Qt.MoveAction)
开发者ID:florianjacob,项目名称:veromix-plasmoid,代码行数:12,代码来源:SinkUI.py

示例12: mouseMoveEvent

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 def mouseMoveEvent(self,event):
     #if the left mouse button is used
     if event.buttons() == Qt.LeftButton:
         data = QByteArray()
         mime_data = QMimeData()
         mime_data.setData(self.mimetext,data)
         drag = QDrag(self)
         drag.setMimeData(mime_data)
         drag.setHotSpot(self.rect().topLeft()) #where do we drag from
         drop_action = drag.start(Qt.MoveAction) #drag starts
开发者ID:34693,项目名称:GraphicalFieldSimulation,代码行数:12,代码来源:graphic_drag_label_class.py

示例13: mouseMoveEvent

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
    def mouseMoveEvent(self, evt):
        if not (evt.buttons()&Qt.LeftButton):
            return
        if (evt.pos()-self.__downPos).manhattanLength()<self.minDragDist:
            return

        D = QDrag(self)
        data = QMimeData()
        data.setData("application/x-internal", '')
        D.setMimeData(data)

        D.exec_(Qt.MoveAction)
开发者ID:mdavidsaver,项目名称:spicetools,代码行数:14,代码来源:dnd.py

示例14: startDrag

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 def startDrag(self):
     image = self.image()
     data = QMimeData()
     data.setImageData(image)
     drag = QDrag(self)
     drag.setMimeData(data)
     if max(image.width(), image.height()) > 256:
         image = image.scaled(QSize(256, 256), Qt.KeepAspectRatio, Qt.SmoothTransformation)
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
开发者ID:WedgeLeft,项目名称:frescobaldi,代码行数:14,代码来源:imageviewer.py

示例15: on_menuSelections_mouseMoved

# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import setMimeData [as 别名]
 def on_menuSelections_mouseMoved(self, event):
     if event.buttons() & Qt.LeftButton and self.seldrag_start_pos:
         if ((event.pos() - self.seldrag_start_pos).manhattanLength() >=
             QApplication.startDragDistance()):
             drag = QDrag(self.menuSelections)
             data = QMimeData()
             data.setText(self.seldrag_selection.name)
             drag.setMimeData(data)
             drag.exec_()
             self.seldrag_start_pos = None
             self.seldrag_selection = None
             self.seldrag_target = None
     QMenu.mouseMoveEvent(self.menuSelections, event)
开发者ID:neurodebian,项目名称:spykeviewer,代码行数:15,代码来源:main_window.py


注:本文中的PyQt4.QtGui.QDrag.setMimeData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。