Hi,
I have a perhaps somewhat unusual setup of a QTableWidget, where the tablewidget contains QLabels as cell-widgets, and those labels contain pixmaps to render something.
The problem: when I drag the columnsseparator to the left, the column separation line disappears.
I have created a simple example of the problem below. Just run it and play around with resizing the columns by dragging the header. Quickly the separation line will disappear. Screenshot:
h2wdjy5.png
code:
{
Q_OBJECT
public:
{
setFixedSize(500,500);
table.setColumnCount(2);
table.setRowCount(1);
table.verticalHeader()->setStretchLastSection(true);
table.
setCellWidget(0,
0, l1
= new QLabel());
table.
setCellWidget(0,
1, l2
= new QLabel());
l->addWidget(&table);
setLayout(l);
}
{
{
pm.fill(Qt::red);
l1->setPixmap(pm);
}
{
pm.fill(Qt::black);
l2->setPixmap(pm);
}
}
};
class mm : public QWidget
{
Q_OBJECT
public:
mm(QWidget* parent = nullptr) : QWidget(parent)
{
setFixedSize(500,500);
table.setColumnCount(2);
table.setRowCount(1);
table.verticalHeader()->setStretchLastSection(true);
table.setCellWidget(0, 0, l1 = new QLabel());
table.setCellWidget(0, 1, l2 = new QLabel());
auto l = new QHBoxLayout();
l->addWidget(&table);
setLayout(l);
}
QLabel *l1, *l2;
QTableWidget table;
void paintEvent(QPaintEvent* e) override
{
{
QPixmap pm(l1->size());
pm.fill(Qt::red);
l1->setPixmap(pm);
}
{
QPixmap pm(l2->size());
pm.fill(Qt::black);
l2->setPixmap(pm);
}
}
};
To copy to clipboard, switch view to plain text mode
Why does this happen and how can I ensure the lines are always drawn?
Happy Holidays!
Bookmarks