本文整理汇总了Python中PyQt4.QtCore.QMimeData.setUrls方法的典型用法代码示例。如果您正苦于以下问题:Python QMimeData.setUrls方法的具体用法?Python QMimeData.setUrls怎么用?Python QMimeData.setUrls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtCore.QMimeData
的用法示例。
在下文中一共展示了QMimeData.setUrls方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startDrag
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [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_()
示例2: startDrag
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [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)
示例3: startDrag
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [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)
示例4: dragFile
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [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)
示例5: mimeData
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [as 别名]
def mimeData(self, indexes):
lst = QgsMimeDataUtils.UriList
for index in indexes:
if index.isValid():
if index.type() == QgsDataItem.Project:
mimeData = QMimeData()
url = QUrl.fromLocalFile(index.path())
mimeData.setUrls([url])
return mimeData
if index.type() == QgsDataItem.Layer:
lst.append(QgsMimeDataUtils.Uri(index))
return QgsMimeDataUtils.encodeUriList(lst)
示例6: mousePressEvent
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [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)
示例7: mousePressEvent
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [as 别名]
def mousePressEvent(self, event):
if event.button() == Qt.LeftButton:
drag = QDrag(self)
data = QMimeData()
data.setData("text/plain", str(self.text()))
path = QDir.tempPath() + "/hello.txt"
f = open(path, "w")
f.write("Hello world!")
f.close()
data.setUrls([QUrl.fromLocalFile(path)])
drag.setMimeData(data)
drag.exec_()
示例8: startDrag
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [as 别名]
def startDrag(self, mainwin, ev):
d = mainwin.currentDocument()
if not d:
return
url = d.url()
if url.isEmpty():
return
drag = QDrag(mainwin)
data = QMimeData()
data.setUrls([url])
drag.setMimeData(data)
pixmap = mainwin.style().standardPixmap(QStyle.SP_FileIcon, 0, mainwin)
hotspot = QPoint(pixmap.width() - 5, 5)
drag.setPixmap(pixmap)
drag.setHotSpot(hotspot)
drag.start(Qt.LinkAction | Qt.CopyAction)
示例9: _drag_urls
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [as 别名]
def _drag_urls ( self, urls ):
mime_data = QMimeData()
mime_data.setUrls( urls )
return mime_data
示例10: _drag_files
# 需要导入模块: from PyQt4.QtCore import QMimeData [as 别名]
# 或者: from PyQt4.QtCore.QMimeData import setUrls [as 别名]
def _drag_files ( self, files ):
mime_data = QMimeData()
mime_data.setUrls( [ QUrl( file ) for file in files ] )
return mime_data