本文整理汇总了Python中PyQt4.QtGui.QDrag.exec_方法的典型用法代码示例。如果您正苦于以下问题:Python QDrag.exec_方法的具体用法?Python QDrag.exec_怎么用?Python QDrag.exec_使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QDrag
的用法示例。
在下文中一共展示了QDrag.exec_方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __onDragStarted
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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)
示例2: startDrag
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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_()
示例3: eventFilter
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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
示例4: startDrag
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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_()
示例5: dragFile
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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)
示例6: mouseMoveEvent
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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)
示例7: startDrag
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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)
示例8: on_menuSelections_mouseMoved
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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)
示例9: __startDrag
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [as 别名]
def __startDrag(self, button):
"""
Start a drag from button
"""
action = button.defaultAction()
desc = action.data() # Widget Description
icon = action.icon()
drag_data = QMimeData()
drag_data.setData("application/vnv.orange-canvas.registry.qualified-name", desc.qualified_name.encode("utf-8"))
drag = QDrag(button)
drag.setPixmap(icon.pixmap(self.iconSize()))
drag.setMimeData(drag_data)
drag.exec_(Qt.CopyAction)
示例10: mousePressEvent
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [as 别名]
def mousePressEvent(self, e):
"""
Start a drag operation
Arguments:
e -- a QMouseEvent
"""
if e.button() == Qt.RightButton:
item = self.itemAt(e.pos())
if item == None:
return
note = item.zoteroItem.get_note()
if note != None:
self.qnotero.previewNote(note)
return
QListWidget.mousePressEvent(self, e)
qnoteroItem = self.currentItem()
if qnoteroItem == None:
return
if not hasattr(qnoteroItem, "zoteroItem"):
return
zoteroItem = qnoteroItem.zoteroItem
if zoteroItem.fulltext == None:
return
path = zoteroItem.fulltext.encode("latin-1")
tmpName = '%s.pdf' % zoteroItem.filename_format()
tmpFile = os.path.join(tempfile.gettempdir(), tmpName)
suffix = 1
while os.path.exists(tmpFile):
tmpName = '%s-%d.pdf' % (zoteroItem.filename_format(), suffix)
tmpFile = os.path.join(tempfile.gettempdir(), tmpName)
suffix += 1
try:
shutil.copy(path, tmpFile)
except:
print "qnoteroResults.mousePressEvent(): failed to copy file, sorry..."
return
print "qnoteroResults.mousePressEvent(): prepare to copy %s" % path
print "qnoteroResults.mousePressEvent(): prepare to copy (tmp) %s" \
% tmpFile
mimeData = QMimeData()
mimeData.setUrls([QUrl.fromLocalFile(tmpFile)])
mimeData.setData("text/plain", tmpFile)
drag = QDrag(self)
drag.setMimeData(mimeData)
drag.exec_(Qt.CopyAction)
示例11: mouseMoveEvent
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [as 别名]
def mouseMoveEvent(self, mouseEvent):
# if mouseEvent.button() != Qt.LeftButton:
# return
if not self._selectedExperiment():
return
if not self.dragStartPosition:
return
if (mouseEvent.pos() - self.dragStartPosition).manhattanLength() < QApplication.startDragDistance():
return
drag = QDrag(self)
mimeData = QMimeData()
mimeData.setText(self._selectedExperiment().__name__)
drag.setMimeData(mimeData)
drag.exec_()
示例12: mousePressEvent
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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()
示例13: mouseMoveEvent
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [as 别名]
def mouseMoveEvent(self, event):
"""Override Qt method"""
if event.buttons() == Qt.MouseButtons(Qt.LeftButton) and \
(event.pos() - self.__drag_start_pos).manhattanLength() > \
QApplication.startDragDistance():
drag = QDrag(self)
mimeData = QMimeData()
mimeData.setData("parent-id", QByteArray.number(id(self.ancestor)))
mimeData.setData("tabwidget-id",
QByteArray.number(id(self.parentWidget())))
mimeData.setData("tabbar-id", QByteArray.number(id(self)))
mimeData.setData("source-index",
QByteArray.number(self.tabAt(self.__drag_start_pos)))
drag.setMimeData(mimeData)
drag.exec_()
QTabBar.mouseMoveEvent(self, event)
示例14: startDrag
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [as 别名]
def startDrag(self, dragData):
"""
Starts a new drag with the inputed data.
:param dragData | <dict>
"""
# create the mime data
mimeData = QMimeData()
for key, value in dragData.items():
mimeData.setData('application/x-%s' % key, wrapVariant(value))
# create the drag instance
drag = QDrag(self.scene().chart())
drag.setMimeData(mimeData)
drag.exec_()
示例15: startDrag
# 需要导入模块: from PyQt4.QtGui import QDrag [as 别名]
# 或者: from PyQt4.QtGui.QDrag import exec_ [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)
p = QPainter()
p.begin(image)
p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
p.fillRect(image.rect(), QColor(0, 0, 0, 160))
p.end()
pixmap = QPixmap.fromImage(image)
drag.setPixmap(pixmap)
drag.setHotSpot(pixmap.rect().center())
drag.exec_(Qt.CopyAction)