Exemple #1
0
    def mousePressEvent(self, event):
        if event.buttons() == Qt.MiddleButton:
            self.mouseIsDown = True
            self.center = self.startCenter = QPoint(event.pos().x(),
                                                    event.pos().y())

        elif event.buttons() == Qt.LeftButton:
            self.mouseIsDown = False
            QTableView.mousePressEvent(self, event)
    def mousePressEvent(self, event):
        if event.button() == Qt.LeftButton:
            ix = self.indexAt(event.pos())

            # When opening combobox, also select current row
            selection = self.selectionModel()
            if selection:
                # select entire row of currently selected index
                top_left = self.model().index(ix.row(), 0)
                bottom_right = self.model().index(ix.row(), 14)
                item_selection = QItemSelection(top_left, bottom_right)

                selection.select(
                    item_selection, QItemSelectionModel.ClearAndSelect)

            QTimer.singleShot(1, self, self.edit(ix))
            event.setAccepted(True)
            return

        QTableView.mousePressEvent(event)