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


Python QDrag.setHotSpot方法代碼示例

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


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

示例1: mousePressEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [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()
開發者ID:skarone,項目名稱:PipeL,代碼行數:36,代碼來源:collapsable_groupbox.py

示例2: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
 def mouseMoveEvent(self,event):
     #if the left mouse button is used
     if event.buttons() == Qt.LeftButton:
         data = QByteArray()
         mime_data = QMimeData()
         mime_data.setData(self.mimetext,data)
         drag = QDrag(self)
         drag.setMimeData(mime_data)
         drag.setHotSpot(self.rect().topLeft()) #where do we drag from
         drop_action = drag.start(Qt.MoveAction) #drag starts
開發者ID:34693,項目名稱:GraphicalFieldSimulation,代碼行數:12,代碼來源:graphic_drag_label_class.py

示例3: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
 def mouseMoveEvent(self, event):
     if event.buttons() != Qt.RightButton:
         return
     mimeData = QMimeData()
     drag = QDrag(self)
     drag.setMimeData(mimeData)
     drag.setHotSpot(event.pos() - self.rect().topLeft())
     dropAction = drag.start(Qt.MoveAction)
     if dropAction == Qt.MoveAction:
         self.close()
開發者ID:calpe20,項目名稱:PYTHONIZANDO,代碼行數:12,代碼來源:tab_central_widget.py

示例4: startDrag

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [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)
開發者ID:WedgeLeft,項目名稱:frescobaldi,代碼行數:14,代碼來源:imageviewer.py

示例5: drag

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
 def drag(self, tile=None, meld=None):
     """returns a drag object"""
     drag = QDrag(self)
     mimeData = MimeData(tile, meld)
     drag.setMimeData(mimeData)
     tile = tile or meld[0]
     graphics = tile.graphics
     tRect = graphics.boundingRect()
     tRect = self.viewportTransform().mapRect(tRect)
     pmapSize = QSize(tRect.width() * graphics.scale(), tRect.height() * graphics.scale())
     pMap = graphics.pixmapFromSvg(pmapSize)
     drag.setPixmap(pMap)
     drag.setHotSpot(QPoint(pMap.width()/2, pMap.height()/2))
     return drag
開發者ID:jsj2008,項目名稱:kdegames,代碼行數:16,代碼來源:board.py

示例6: startDrag

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [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:arnaldorusso,項目名稱:frescobaldi,代碼行數:18,代碼來源:icon_drag_eventhandler.py

示例7: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
    def mouseMoveEvent(self, event):
        if event.buttons() != Qt.LeftButton:
            return

        mimeData = QMimeData()
        if self.pos == -1:
            return
        mimeData.setData("splitter/fragment", QByteArray.number(self.pos))
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(event.pos() - self.rect().topLeft())

        dropAction = drag.start(Qt.MoveAction)

        if dropAction == Qt.MoveAction:
            self.close()
開發者ID:maximerobin,項目名稱:Ufwi,代碼行數:18,代碼來源:fragment_frame.py

示例8: startDrag

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [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)
開發者ID:uliska,項目名稱:frescobaldi,代碼行數:19,代碼來源:imageviewer.py

示例9: startDrag

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [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

示例10: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [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

示例11: startDrag

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
    def startDrag(self, drop_actions):
        selected_doc_items = self.selectedItems()
        data = QByteArray()
        stream = QDataStream(data, QIODevice.WriteOnly)

        for doc_item in selected_doc_items:
            stream.writeQString(doc_item.text() + ":" + doc_item.get_full_name())

        mimeData = QMimeData()
        mimeData.setData("application/x-doc-list", data)

        drag = QDrag(self)
        drag.setMimeData(mimeData)
        drag.setHotSpot(QPoint(0, 0))

        if drag.start(Qt.MoveAction) == Qt.MoveAction:
            docs = []
            for doc_item in selected_doc_items:
                # self.takeItem(self.row(doc_item))
                docs.append(doc_item.text())
            self.emit(SIGNAL("removeDocs"), docs)
開發者ID:FlyBoy8869,項目名稱:AssemblyDocTracker,代碼行數:23,代碼來源:document_list_widget.py

示例12: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [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

示例13: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
    def mouseMoveEvent(self, event):
        drag = QDrag(event.widget())
        data = QMimeData()
        data.setText(self.commit.name())

        drag.setMimeData(data)

        #data.setColorData(GREEN)
        pixmap = QPixmap(COMMIT_WIDTH, COMMIT_HEIGHT)
        pixmap.fill(WHITE)
        painter = QPainter(pixmap)
        painter.translate(0, 0)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setPen(Qt.NoPen)
        painter.setBrush(QBrush(self.color))
        painter.drawPath(self.setup_display(0, 0))
        painter.end()

        pixmap.setMask(pixmap.createHeuristicMask())
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(0, 0))
        drag.start()
開發者ID:mike-perdide,項目名稱:gitbuster,代碼行數:24,代碼來源:graphics.py

示例14: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
    def mouseMoveEvent(self, event):
        if not (event.buttons() and Qt.LeftButton):
            return
        currentItem = self.currentItem()
        if(currentItem.isFile()):
            if(currentItem.isPic()):
                currentItemName = self.currentItem().getPath()
                data = QByteArray()
                stream = QDataStream(data, QIODevice.WriteOnly)
                stream.writeQString(currentItemName)
                
                icon = Icons.image
                pixmap = icon.pixmap(64, 64)
 
                mimeData = QMimeData()
                mimeData.setText(currentItemName)
                mimeData.setData('application/x-item', data)
 
                drag = QDrag(self)
                drag.setPixmap(pixmap)
                drag.setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2))  
                drag.setMimeData(mimeData)
                dropAction = drag.start(Qt.CopyAction)
開發者ID:pyros2097,項目名稱:SabelIDE,代碼行數:25,代碼來源:tree.py

示例15: mouseMoveEvent

# 需要導入模塊: from PyQt4.QtGui import QDrag [as 別名]
# 或者: from PyQt4.QtGui.QDrag import setHotSpot [as 別名]
	def mouseMoveEvent(self, e):
		# Chequear que se esté presionando el botón izquierdo
		if e.buttons() != Qt.LeftButton:
			return

		# posicion del click dentro del gmod
		mimeData = QMimeData()

		pixmap = QPixmap.grabWidget(self)
		painter = QPainter(pixmap)
		painter.setCompositionMode(painter.CompositionMode_DestinationIn)
		painter.fillRect(pixmap.rect(), QColor(0, 0, 0, 127))
		painter.end()

		drag = QDrag(self)
		# escribir el MimeData
		drag.setMimeData(mimeData)
		# establecer el Pixmap
		drag.setPixmap(pixmap)
		# posicionar correctamente el pixmap
		drag.setHotSpot(e.pos())

		drag.exec_(Qt.MoveAction)
開發者ID:LJavierG,項目名稱:thesis-cyphers-block-construction,代碼行數:25,代碼來源:labmod.py


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