The bottom border of table header is gone again
-
Re: formatting a QTableView header
@Christian-Ehrlicher @SGaist @kshegunov
Hi all, I noted that you have discussed about the related issue in the above topic. And seemly that issue has been fixed. But I reproduced it in some specified situations in windows with Qt 5.14.2 recently.
It works fine if display a table view in the dialog directly. But the bottom border of table header is gone when the table view is added into a tab widget and then display that tab widget in the dialog. I'm not sure if it's a bug. Hope you could give me a hint if you have any idea about that. Thanks.
Border is shown:
QTableView* table = new QTableView; table ->horizontalHeader()->setFrameShape(QFrame::HLine); // show border here ... QVBoxLayout* layout = new QVBoxLayout; layout ->addWidget(table); QDialog* dialog = new QDialog; dialog ->setLayout(layout); dialog ->show();
Border is missing:
QTableView* table = new QTableView; table ->horizontalHeader()->setFrameShape(QFrame::HLine); // doesn't work ... QVBoxLayout* layout1 = new QVBoxLayout; layout1 ->addWidget(table); QTabWidget* tab = new QTabWidget; tab->setLayout(layout1); QVBoxLayout* layout2 = new QVBoxLayout; layout2 ->addWidget(tab); QDialog* dialog = new QDialog; dialog ->setLayout(layout2 ); dialog ->show();
-
@Lee908 said in The bottom border of table header is gone again:
QTabWidget* tab = new QTabWidget;
tab->setLayout(layout1);I have no idea whether it relates to your issue, but you are not supposed to set a layout on a
QTabWidget
. It is a container widget, all you are supposed to do isaddTab()
for the various pages. They can/should be given a layout, but not theQTabWidget
. -
@JonB said in The bottom border of table header is gone again:
It is a container widget, all you are supposed to do is addTab()
Make a small improvement on my test: create 2 table views with same data and format in a dialog. The left one is added into layout directly, the right one is added via a tab widget as your suggestion. The header bottom border is still missing in the right.
QTableView* table1 = new QTableView; QTableView* table2 = new QTableView; table1 ->horizontalHeader()->setFrameShape(QFrame::HLine); table2 ->horizontalHeader()->setFrameShape(QFrame::HLine); ... QVBoxLayout* layout = new QVBoxLayout; layout ->addWidget(table1); QTabWidget* tab = new QTabWidget; tab->addTab(table2, "Bottom border is missing in header"); layout ->addWidget(tab); QDialog* dialog = new QDialog; dialog ->setLayout(layout); dialog ->show();