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:

Qt Code:
  1. class mm : public QWidget
  2. {
  3. Q_OBJECT
  4. public:
  5. mm(QWidget* parent = nullptr) : QWidget(parent)
  6. {
  7. setFixedSize(500,500);
  8. table.setColumnCount(2);
  9. table.setRowCount(1);
  10. table.verticalHeader()->setStretchLastSection(true);
  11.  
  12. table.setCellWidget(0, 0, l1 = new QLabel());
  13. table.setCellWidget(0, 1, l2 = new QLabel());
  14.  
  15. auto l = new QHBoxLayout();
  16. l->addWidget(&table);
  17. setLayout(l);
  18. }
  19.  
  20. QLabel *l1, *l2;
  21. QTableWidget table;
  22.  
  23. void paintEvent(QPaintEvent* e) override
  24. {
  25. {
  26. QPixmap pm(l1->size());
  27. pm.fill(Qt::red);
  28. l1->setPixmap(pm);
  29. }
  30. {
  31. QPixmap pm(l2->size());
  32. pm.fill(Qt::black);
  33. l2->setPixmap(pm);
  34. }
  35. }
  36. };
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!