Exemplo n.º 1
0
    def dragMoveEvent(self, event: QDragMoveEvent):
        if event.mimeData().hasText():
            self.curRow = 0
            index = self.indexAt(event.pos())
            if index.isValid():
                if event.pos().y(
                ) - index.row() * self.itemRowHeight >= self.itemRowHeight / 2:
                    self.curRow = index.row() + 1
                else:
                    self.curRow = index.row()
            else:
                self.curRow = self.model.rowCount()

            self.targetRow = self.curRow
            self.lineLabel.setGeometry(
                1, self.headerHeight + self.targetRow * self.itemRowHeight,
                self.width() - 2, 2)
            event.acceptProposedAction()
            return
        event.ignore()
        QTableView.dragMoveEvent(self, event)