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


Python QDrag.setPixmap方法代码示例

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


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

示例1: mouseMoveEvent

# 需要导入模块: from PyQt5.Qt import QDrag [as 别名]
# 或者: from PyQt5.Qt.QDrag import setPixmap [as 别名]
 def mouseMoveEvent(self, event):
     dex = self.indexAt(event.pos())
     if dex.isValid():
         self.setCursor(Qt.PointingHandCursor)
     else:
         self.unsetCursor()
     if not event.buttons() & Qt.LeftButton:
         return
     if self.in_drag_drop or not dex.isValid():
         QTreeView.mouseMoveEvent(self, event)
         return
     # Must deal with odd case where the node being dragged is 'virtual',
     # created to form a hierarchy. We can't really drag this node, but in
     # addition we can't allow drag recognition to notice going over some
     # other node and grabbing that one. So we set in_drag_drop to prevent
     # this from happening, turning it off when the user lifts the button.
     self.in_drag_drop = True
     if not self._model.flags(dex) & Qt.ItemIsDragEnabled:
         QTreeView.mouseMoveEvent(self, event)
         return
     md = self._model.mimeData([dex])
     pixmap = dex.data(DRAG_IMAGE_ROLE).pixmap(self.iconSize())
     drag = QDrag(self)
     drag.setPixmap(pixmap)
     drag.setMimeData(md)
     if self._model.is_in_user_category(dex):
         drag.exec_(Qt.CopyAction|Qt.MoveAction, Qt.CopyAction)
     else:
         drag.exec_(Qt.CopyAction)
开发者ID:Aliminator666,项目名称:calibre,代码行数:31,代码来源:view.py

示例2: drag_data

# 需要导入模块: from PyQt5.Qt import QDrag [as 别名]
# 或者: from PyQt5.Qt.QDrag import setPixmap [as 别名]
 def drag_data(self):
     m = self.model()
     rows = self.selectionModel().selectedRows()
     paths = [force_unicode(p, enc=filesystem_encoding) for p in m.paths(rows) if p]
     md = QMimeData()
     md.setData("application/calibre+from_device", b"dummy")
     md.setUrls([QUrl.fromLocalFile(p) for p in paths])
     drag = QDrag(self)
     drag.setMimeData(md)
     cover = self.drag_icon(m.cover(self.currentIndex().row()), len(paths) > 1)
     drag.setHotSpot(QPoint(-15, -15))
     drag.setPixmap(cover)
     return drag
开发者ID:mihailim,项目名称:calibre,代码行数:15,代码来源:views.py

示例3: drag_data

# 需要导入模块: from PyQt5.Qt import QDrag [as 别名]
# 或者: from PyQt5.Qt.QDrag import setPixmap [as 别名]
def drag_data(self):
    m = self.model()
    db = m.db
    selected = self.get_selected_ids()
    ids = ' '.join(map(str, selected))
    md = QMimeData()
    md.setData('application/calibre+from_library', ids.encode('utf-8'))
    fmt = prefs['output_format']

    def url_for_id(i):
        try:
            ans = db.format_path(i, fmt, index_is_id=True)
        except:
            ans = None
        if ans is None:
            fmts = db.formats(i, index_is_id=True)
            if fmts:
                fmts = fmts.split(',')
            else:
                fmts = []
            for f in fmts:
                try:
                    ans = db.format_path(i, f, index_is_id=True)
                except:
                    ans = None
        if ans is None:
            ans = db.abspath(i, index_is_id=True)
        return QUrl.fromLocalFile(ans)

    md.setUrls([url_for_id(i) for i in selected])
    drag = QDrag(self)
    col = self.selectionModel().currentIndex().column()
    try:
        md.column_name = self.column_map[col]
    except AttributeError:
        md.column_name = 'title'
    drag.setMimeData(md)
    cover = self.drag_icon(m.cover(self.currentIndex().row()),
            len(selected) > 1)
    drag.setHotSpot(QPoint(-15, -15))
    drag.setPixmap(cover)
    return drag
开发者ID:JimmXinu,项目名称:calibre,代码行数:44,代码来源:alternate_views.py


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