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


Python QMimeData.setUrls方法代码示例

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


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

示例1: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setUrls [as 别名]
 def mimeData(self, indexes):
     """
     Public method to return the mime data.
     
     @param indexes list of indexes (QModelIndexList)
     @return mime data (QMimeData)
     """
     from .XbelWriter import XbelWriter
     
     data = QByteArray()
     stream = QDataStream(data, QIODevice.WriteOnly)
     urls = []
     
     for index in indexes:
         if index.column() != 0 or not index.isValid():
             continue
         
         encodedData = QByteArray()
         buffer = QBuffer(encodedData)
         buffer.open(QIODevice.ReadWrite)
         writer = XbelWriter()
         parentNode = self.node(index)
         writer.write(buffer, parentNode)
         stream << encodedData
         urls.append(index.data(self.UrlRole))
     
     mdata = QMimeData()
     mdata.setData(self.MIMETYPE, data)
     mdata.setUrls(urls)
     return mdata
开发者ID:testmana2,项目名称:test,代码行数:32,代码来源:BookmarksModel.py

示例2: dragFile

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.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)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:12,代码来源:drag.py

示例3: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setUrls [as 别名]
 def mimeData(self, indexes):
     """
     Public method to return the mime data.
     
     @param indexes list of indexes (QModelIndexList)
     @return mime data (QMimeData)
     """
     mimeData = QMimeData()
     urls = []
     for index in indexes:
         if index.isValid():
             itm = self.__manager.downloads()[index.row()]
             urls.append(QUrl.fromLocalFile(itm.absoluteFilePath()))
     mimeData.setUrls(urls)
     return mimeData
开发者ID:testmana2,项目名称:test,代码行数:17,代码来源:DownloadModel.py

示例4: mimeData

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setUrls [as 别名]
 def mimeData(self, indexes):
     """
     Public method to return the mime data.
     
     @param indexes list of indexes (QModelIndexList)
     @return mime data (QMimeData)
     """
     urls = []
     for index in indexes:
         url = index.data(HistoryModel.UrlRole)
         urls.append(url)
     
     mdata = QMimeData()
     mdata.setUrls(urls)
     return mdata
开发者ID:Darriall,项目名称:eric,代码行数:17,代码来源:HistoryMenu.py

示例5: startDrag

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.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)
开发者ID:AlexSchr,项目名称:frescobaldi,代码行数:18,代码来源:icon_drag_eventhandler.py

示例6: test_EditorPane_drop_event

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setUrls [as 别名]
def test_EditorPane_drop_event():
    """
    If there's a drop event associated with files, cause them to be passed into
    Mu's existing file loading code.
    """
    ep = mu.interface.editor.EditorPane(None, 'baz')
    m = mock.MagicMock()
    ep.open_file = mock.MagicMock()
    ep.open_file.emit = m
    data = QMimeData()
    data.setUrls([QUrl('file://test/path.py'), QUrl('file://test/path.hex'),
                  QUrl('file://test/path.txt')])
    evt = QDropEvent(QPointF(0, 0), Qt.CopyAction, data,
                     Qt.LeftButton, Qt.NoModifier)
    ep.dropEvent(evt)
    # Upstream _load will handle invalid file type (.txt).
    assert m.call_count == 3
开发者ID:willingc,项目名称:mu,代码行数:19,代码来源:test_editor.py

示例7: mouseMoveEvent

# 需要导入模块: from PyQt5.QtCore import QMimeData [as 别名]
# 或者: from PyQt5.QtCore.QMimeData import setUrls [as 别名]
 def mouseMoveEvent(self, evt):
     """
     Protected method to handle mouse move events.
     
     @param evt reference to the mouse event (QMouseEvent)
     """
     if evt.button() == Qt.LeftButton and \
        (evt.pos() - self.__dragStartPos).manhattanLength() > \
             QApplication.startDragDistance() and \
        self.__browser is not None:
         drag = QDrag(self)
         mimeData = QMimeData()
         title = self.__browser.title()
         if title == "":
             title = str(self.__browser.url().toEncoded(), encoding="utf-8")
         mimeData.setText(title)
         mimeData.setUrls([self.__browser.url()])
         p = self.pixmap()
         if p:
             drag.setPixmap(p)
         drag.setMimeData(mimeData)
         drag.exec_()
开发者ID:testmana2,项目名称:test,代码行数:24,代码来源:FavIconLabel.py


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