def is_overlap(rect1: QRectF, rect2: QRectF): if rect1.x() + rect1.width() > rect2.x() and\ rect2.x() + rect2.width() > rect1.x() and\ rect1.y() + rect1.height() > rect2.y() and\ rect2.y() + rect2.height() > rect1.y(): return True else: return False
def updateBoundingRect(self): margin = self.keySize * 0.5 boundingRect = QRectF(0, 0, 0, 0) for key in self.keyList: rect = key.shape().boundingRect() rect.translate(key.pos()) boundingRect = boundingRect.united(rect) boundingRect.setX(boundingRect.x() - margin) boundingRect.setY(boundingRect.y() - margin) boundingRect.setWidth(boundingRect.width() + margin) boundingRect.setHeight(boundingRect.height() + margin) self.keyBoundRect = boundingRect