How to draw a continuous vertical line on QTableView?
-
Hi,
- Qt Version: 5.9.7
- Must be using QTableView to create tables.
- There must be gridlines (horizontal and vertical) for Table items.
- We add pushbuttons using setIndexWidget to some cells.
- We want to create a vertical line with blue color on right side of these cells. (with pushbuttons)
We used following code block to create blue border at the right of the cells:
QPushButton *push_button = new QPushButton(); push_button ->setStyleSheet("border-right: 3px solid blue;" "padding-right: 4px;" "background-color:none;"); setIndexWidget(in_p_model->index(row_idx,column_idx), push_button );
The resulting table is shown below.
What is not acceptable for us is table gridlines(gray) overlap on our blue lines that we have created.
We want vertical like below (We drew at paint :D )
Please let us know how can we prevent gridlines to overlap our vertical lines (blue) ?
Many Thanks, -
Hi, I had almost same problem, for a QTableWidget, and I wanted an horizontal line unobscured by the gridlies.
I ended up created an horizontal QFrame:
... auto qf = new QFrame(ui->tableWidget->viewport()); qf->setFrameShape(QFrame::HLine); qf->setFrameShadow(QFrame::Plain); qf->show(); ....
(and I calculated the width etc. from ui->listWidget->viewport()->width() and ui->listWidget0->rowAt(0) ..)
-
We tried the codeblock you've shared but it does not show anything. Please could you share remaining parts of the code.
QFrame* Frame = new QFrame(this->viewport()); Frame ->setFrameShape(QFrame:VLine); Frame ->setFrameShadow(QFrame::Plain); Frame ->show(); setIndexWidget(in_p_model->index(row_idx,column_idx), Frame);
-
@mehmety888
@hskoglund wrote to you:(and I calculated the width etc. from ui->listWidget->viewport()->width() and ui->listWidget0->rowAt(0) ..)
How did you act on that?
-
@JonB Ok I understand now why it is not shown. I needed to set the border width.
p_frame->setFixedHeight(total_cell_height); p_frame->setStyleSheet( "border-width: 3px;" "border-top-style: none;" "border-right-style: solid;" "border-bottom-style: none;" "border-left-style: none;" "border-color: blue;");
-
@hskoglund Many thanks for your help :)