Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to draw a continuous vertical line on QTableView?
Forum Updated to NodeBB v4.3 + New Features

How to draw a continuous vertical line on QTableView?

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 2.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mehmety888
    wrote on 4 Jun 2020, 13:12 last edited by mehmety888 6 Apr 2020, 14:55
    #1

    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.
    vline.png

    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 )
    vlinesolved.jpg

    Please let us know how can we prevent gridlines to overlap our vertical lines (blue) ?
    Many Thanks,

    1 Reply Last reply
    2
    • H Offline
      H Offline
      hskoglund
      wrote on 4 Jun 2020, 13:22 last edited by
      #2

      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) ..)

      M 2 Replies Last reply 4 Jun 2020, 14:59
      3
      • H hskoglund
        4 Jun 2020, 13:22

        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) ..)

        M Offline
        M Offline
        mehmety888
        wrote on 4 Jun 2020, 14:59 last edited by
        #3

        @hskoglund

        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);
        
        J 1 Reply Last reply 4 Jun 2020, 15:51
        0
        • M mehmety888
          4 Jun 2020, 14:59

          @hskoglund

          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);
          
          J Offline
          J Offline
          JonB
          wrote on 4 Jun 2020, 15:51 last edited by
          #4

          @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?

          M 1 Reply Last reply 5 Jun 2020, 08:20
          1
          • J JonB
            4 Jun 2020, 15:51

            @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?

            M Offline
            M Offline
            mehmety888
            wrote on 5 Jun 2020, 08:20 last edited by
            #5

            @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;");
            
            1 Reply Last reply
            0
            • H hskoglund
              4 Jun 2020, 13:22

              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) ..)

              M Offline
              M Offline
              mehmety888
              wrote on 5 Jun 2020, 08:20 last edited by
              #6

              @hskoglund Many thanks for your help :)

              1 Reply Last reply
              0

              2/6

              4 Jun 2020, 13:22

              4 unread
              • Login

              • Login or register to search.
              2 out of 6
              • First post
                2/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved