示例#1
0
    def __init__(self, value, parent=None):
        QtGui.QWidget.__init__(self, parent)
        layout = QtGui.QGridLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)
        self._widget = None

        self.__status = QtGui.QLabel(self)
        self.__status.setContentsMargins(5, 0, 0, 0)
        layout.addWidget(self.__status, 0, 2)

        if not FormWidget.__LOCKED_PIX:
            FormWidget.__LOCKED_PIX = QtGui.QPixmap(":/images/locked.png")
            FormWidget.__LOCKED_PIX = FormWidget.__LOCKED_PIX.scaled(
                QtCore.QSize(12, 12), QtCore.Qt.KeepAspectRatio,
                QtCore.Qt.SmoothTransformation)
示例#2
0
    def mouseMoveEvent(self, event):
        startDrag = QtGui.QApplication.startDragDistance()

        if (event.pos() - self.__dragStartPos).manhattanLength() < startDrag:
            return

        mimeData = QtCore.QMimeData()
        data = cPickle.dumps(self.mapToParent(self.__dragStartPos))
        mimeData.setData("application/x-DragDropList", QtCore.QByteArray(data))

        pix = QtGui.QPixmap(self.size())
        self.render(pix)

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pix)
        drag.setHotSpot(event.pos())
        drag.exec_(QtCore.Qt.MoveAction)