當前位置: 首頁>>代碼示例>>Python>>正文


Python QDrag.pixmap方法代碼示例

本文整理匯總了Python中PyQt4.QtGui.QDrag.pixmap方法的典型用法代碼示例。如果您正苦於以下問題:Python QDrag.pixmap方法的具體用法?Python QDrag.pixmap怎麽用?Python QDrag.pixmap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PyQt4.QtGui.QDrag的用法示例。


在下文中一共展示了QDrag.pixmap方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: startDrag

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import pixmap [as 別名]
    def startDrag(self, supportedActions):
        """ Overwritten function of QTreeWidget.

        This function creates a QDrag object representing the selected element of this TreeWidget.
        """
        logging.debug(self.__class__.__name__ +": startDrag()")
        indexes = self.selectedIndexes()
        if len(indexes) > 0:
            data = self.model().mimeData(indexes)
            if not data:
                return
            drag = QDrag(self)
            drag.setMimeData(data)
            if self.model().data(indexes[0], Qt.DecorationRole).type() == QVariant.Icon:
                icon = QIcon(self.model().data(indexes[0], Qt.DecorationRole))
                drag.setPixmap(icon.pixmap(QSize(50, 50)))
                drag.setHotSpot(QPoint(drag.pixmap().width()/2, drag.pixmap().height()/2))  # center icon in respect to cursor
            defaultDropAction = Qt.IgnoreAction
            drag.exec_(supportedActions, defaultDropAction)
開發者ID:Moanwar,項目名稱:cmssw,代碼行數:21,代碼來源:SimpleDraggableTreeWidget.py

示例2: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import pixmap [as 別名]
    def mouseMoveEvent(self, e):
        if self.drag_start is None:
            pass
        x = e.x() - self.drag_start.x()
        y = e.y() - self.drag_start.y()
        dist = QApplication.startDragDistance()
        if not self.draggable or x > dist or y > dist:
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self.__class__.__name__)
        mime.part = self
        drag.setMimeData(mime)
        pixmap = QPixmap.grabWidget(self)
        pixmap.setAlphaChannel(pixmap)
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                               drag.pixmap().height()))
        drag.start(Qt.CopyAction)
開發者ID:patrickkidd,項目名稱:pksampler,代碼行數:22,代碼來源:parts.py

示例3: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import pixmap [as 別名]
    def mouseMoveEvent(self, e):
        if self.drag_start is None:
            pass
        x = e.x() - self.drag_start[0]
        y = e.y() - self.drag_start[1]
        dist = QApplication.startDragDistance()
        if (self.draggable is False) or (abs(x) < dist and abs(y) < dist):
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self.__class__.__name__)
        mime.part = self
        drag.setMimeData(mime)
        pixmap = QPixmap.grabWidget(self)
        pixmap.setAlphaChannel(pixmap)
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                               drag.pixmap().height()))
        self.dragging = True
        drag.start(Qt.CopyAction)
開發者ID:RikVerschueren,項目名稱:AccordionMega,代碼行數:23,代碼來源:parts.py


注:本文中的PyQt4.QtGui.QDrag.pixmap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。