How to make QTableWidgets full of gridlines
-
Hi @jronald,
With stylesheet:
ui->tableView->setStyleSheet("QTableView{border : 1px solid red}");
sourceOr using a delegate: (python code)
class GridDelegate(QStyledItemDelegate): def __init__(self, borderColor=None, parent=None): super().__init__(parent) self.bordelColor = borderColor def paint(self, painter, option, index): painter.save() painter.setPen(QColor(self.borderColor or '#aaa')) # painter.drawRect(option.rect) painter.drawRoundedRect(option.rect, 8, 8) painter.restore() return super().paint(painter, option, index) #... myTableView.setItemDelegate(GridDelegate)
-
-
@jronald This is probably the solution you're looking for:
ui->tableView->setStylesheet("QTableView {gridline-color: red}"); ui->tableView->horizontalHeader()->setStyleSheet("::section{border: 1px solid blue;}"); ui->tableView->verticalHeader()->setStyleSheet("::section{border: 1px solid green;}");
-
@Gojir4 said in How to make QTableWidgets full of gridlines:
ui->tableView->setStylesheet("QTableView {gridline-color: red}");
ui->tableView->horizontalHeader()->setStyleSheet("::section{border: 1px solid blue;}");
ui->tableView->verticalHeader()->setStyleSheet("::section{border: 1px solid green;}");Not perfect
-
@jronald said in How to make QTableWidgets full of gridlines:
I think it might be the difference between free version and non-free version.
I don't think so, since they are identical in this and most respects (the only differences being extras which come with the commercial version, plus The Qt Company's support) :) What induces you to make such a statement?
-
@JonB said in How to make QTableWidgets full of gridlines:
I don't think so, since they are identical in this and most respects (the only differences being extras which come with the commercial version, plus The Qt Company's support) :) What induces you to make such a statement?
Because it's obvious that tables show as below by default are not as expected, and it's not hard to fix.
For a non-free version, if you ask for the company for support for such problems, patches might have been already there. -
@Bonnie said in How to make QTableWidgets full of gridlines:
@jronald No, that's because on Linux it is using fusion style while Windows ones using windows vista style.
On Windows it can also be set to use fusion style.
Take a look at QStyle.Thanks very much, it must help.
-
@jronald said in How to make QTableWidgets full of gridlines:
Because it's obvious that tables shows as below by default is not expected, and it's not hard to fix.
Since you choose to reply to me, what in the world does this have to do with your statement that the difference is between the commercial and free versions of Qt? You are suggesting to other readers that there is such a difference, which is just misleading.
And since you have acknowledged that @Bonnie's answer about your choice of Fusion vs Vista style is the reason for the difference, you know that commercial vs open source is not at issue.
-
@jronald said in How to make QTableWidgets full of gridlines:
Because it's obvious that tables shows as below by default is not expected, and it's not hard to fix.
Do you really think that the only possible explanation for this issue is that "difference between free version and non-free version"?!
Open source and commercial Qt use same code base. The only difference is the license and some additional modules/tools available onyl for commercial users. QWidgets module is exactly the same... -
@jsulm said in How to make QTableWidgets full of gridlines:
Do you really think that the only possible explanation for this issue is that "difference between free version and non-free version"?!
Open source and commercial Qt use same code base. The only difference is the license and some additional modules/tools available onyl for commercial users. QWidgets module is exactly the same...Also supports by the company, patches might be there.
-
@JonB said in How to make QTableWidgets full of gridlines:
@jronald said in How to make QTableWidgets full of gridlines:
Because it's obvious that tables shows as below by default is not expected, and it's not hard to fix.
Since you choose to reply to me, what in the world does this have to do with your statement that the difference is between the commercial and free versions of Qt? You are suggesting to other readers that there is such a difference, which is just misleading.
And since you have acknowledged that @Bonnie's answer about your choice of Fusion vs Vista style is the reason for the difference, you know that commercial vs open source is not at issue.
At first sorry for my grammar, I should review it before posting.
Anyway I think the default style on Windows is not as expected, for a comercial license, the customer can ask for support to fix it.
With fusion style, as the screenshot shows, it is still not perfect. -
@jronald said in How to make QTableWidgets full of gridlines:
for a comercial license, the customer can ask support to fix it.
I don't know what to say. Get a commercial licence and then see what The Qt Company has to say when you/your end-user tries to ask them to "fix" this (intended) behaviour.
-
@jronald said in How to make QTableWidgets full of gridlines:
Also supports by the company, patches might be there
Don't know what you mean. What company? What patches? What support?
All Qt patches are merged into mainline and released. The only difference is that open source users do not get Qt binaries for point releses (5.15.x). But open source users can download the source code and build by themselfs...
Support from QtCompany requires a commercial license, yes - but this has NOTHING to do with Qt itself... -
@jsulm said in How to make QTableWidgets full of gridlines:
@jronald said in How to make QTableWidgets full of gridlines:
Also supports by the company, patches might be there
Don't know what you mean. What company?
Qt
What patches?
patches to fix the lines in QTableWidget / QTableView
What support?
paid support
All Qt patches are merged into mainline and released. The only difference is that open source users do not get Qt binaries for point releses (5.15.x). But open source users can download the source code and build by themselfs...
Support from QtCompany requires a commercial license, yes - but this has NOTHING to do with Qt itself...If you are comfortable with the default table styles as in the screenshots below, you are right