'Problem with QWidget borders in a QGridLayout
I have a QGridLayout filled with my custom QWidgets (I'll call them CellWidgets). I want to display a grid between all of the CellWidgets so the columns and rows are clearly visible.
Obviously this isn't done from QGridLayout, as that is simply a holder for widgets that draw themseleves. I made my CellWidgets draw a border by over-riding the paintEvent function like so:
QPainter Painter(this);
Painter.setPen(QPen(QBrush(Qt::white), 2));
Painter.setBrush(Qt::black);
Painter.drawRect(0, 0, width(), height());
The QGridLayout spacing is set to 0, however, when it is drawn the grid border has a single width around the edges and double that width between cells, as the border of the cell is effectively being displayed twice.
Any clean way to solve/avoid this problem?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
