diff --git a/qt/board_widget.cpp b/qt/board_widget.cpp index 6e631bc..20f0f88 100644 --- a/qt/board_widget.cpp +++ b/qt/board_widget.cpp @@ -197,10 +197,11 @@ void BoardWidget::paintEvent(QPaintEvent *) const int size = boardLayout->getSquareSize(); const int spacing = boardLayout->spacing(); + // Draw lines between tiles QLine hLine(0, 0, rect.width() + 1, 0); QLine vLine(0, 0, 0, rect.height() + 1); - hLine.translate(size, size); - vLine.translate(size, size); + hLine.translate(rect.left() - 1, rect.top() - 1); + vLine.translate(rect.left() - 1, rect.top() - 1); for (int i = 0; i <= BOARD_MAX; ++i) { painter.drawLine(hLine); @@ -208,7 +209,7 @@ void BoardWidget::paintEvent(QPaintEvent *) hLine.translate(0, size + spacing); vLine.translate(size + spacing, 0); } - //painter.drawRect(rect); + // Draw a second line around the board, so that it looks nicer painter.drawRect(rect.adjusted(-2, -2, 1, 1)); } diff --git a/qt/tile_layout.cpp b/qt/tile_layout.cpp index bba448e..eaa182b 100644 --- a/qt/tile_layout.cpp +++ b/qt/tile_layout.cpp @@ -178,12 +178,12 @@ void TileLayout::setGeometry(const QRect &rect) const int squareSize = squareSizeWithSpacing - spacing(); // Handle margins and alignment - int x = contentsMargins().left(); + int x = contentsRect().left() + contentsMargins().left(); if (alignment() & Qt::AlignRight) x += width - m_nbCols * squareSizeWithSpacing; else if (alignment() & Qt::AlignHCenter) x += (width - m_nbCols * squareSizeWithSpacing) / 2; - int y = contentsMargins().top(); + int y = contentsRect().top() + contentsMargins().top(); if (alignment() & Qt::AlignBottom) y += height - m_nbRows * squareSizeWithSpacing; else if (alignment() & Qt::AlignVCenter)