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 can I hide the borders of the cells in a QTableView?
Forum Updated to NodeBB v4.3 + New Features

How can I hide the borders of the cells in a QTableView?

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 4.3k Views
  • 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.
  • S Offline
    S Offline
    Simmania
    wrote on last edited by
    #1

    Hi,
    I'm using a QTableView with my own abstract data model. All works fine. But I would like to hide the lines between the cells. I can not find the methods to do that.

    jsulmJ 1 Reply Last reply
    0
    • S Simmania

      Hi,
      I'm using a QTableView with my own abstract data model. All works fine. But I would like to hide the lines between the cells. I can not find the methods to do that.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @Simmania Search for QTableView in https://doc.qt.io/qt-5/stylesheet-reference.html
      And https://doc.qt.io/qt-5/stylesheet-reference.html#gridline-color-prop

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Simmania
        wrote on last edited by
        #3

        Thx
        I'm new to the stylesheet approach. I tried this to see if I can control the style:

        mTableView->setStyleSheet(QString("QTableView { border-color: red; border-style: solid; border-width: 1px; }"));
        

        But that doesn't work. Is "QTableView" the correct selector?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Simmania
          wrote on last edited by Simmania
          #4

          I found out that this one works:

          mTableView->setStyleSheet(QString("QTableView { gridline-color: red; }"));
          

          But I can not find how to remove the grid.
          How can I find out which properties can be controlled and with values are allowed?

          jsulmJ 1 Reply Last reply
          0
          • S Simmania

            I found out that this one works:

            mTableView->setStyleSheet(QString("QTableView { gridline-color: red; }"));
            

            But I can not find how to remove the grid.
            How can I find out which properties can be controlled and with values are allowed?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @Simmania said in How can I hide the borders of the cells in a QTableView?:

            But I can not find how to remove the grid

            Set same color for the grid as is used as background color, then the grid will not be visible.

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              Simmania
              wrote on last edited by
              #6

              That is not possible, because I want to color the background of the cells too (can be different per cell).

              jsulmJ 1 Reply Last reply
              0
              • S Simmania

                That is not possible, because I want to color the background of the cells too (can be different per cell).

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Simmania Sinse you can use RGBA colors you can simply specify a transparent color for gridline-color (A channel set to0.0).

                mTableView->setStyleSheet(QString("QTableView { gridline-color: rgba(255,0,0,0.0); }"));
                

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                S 1 Reply Last reply
                1
                • jsulmJ jsulm

                  @Simmania Sinse you can use RGBA colors you can simply specify a transparent color for gridline-color (A channel set to0.0).

                  mTableView->setStyleSheet(QString("QTableView { gridline-color: rgba(255,0,0,0.0); }"));
                  
                  S Offline
                  S Offline
                  Simmania
                  wrote on last edited by
                  #8

                  @jsulm aah, off course!

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Simmania
                    wrote on last edited by
                    #9

                    I also found this one:

                    mTableView->setShowGrid(false);
                    

                    And it works!

                    With the stylesheets there may be much more control possible, but I have a hard time finding out which selection class to use en what the possible properties are.

                    jsulmJ 1 Reply Last reply
                    2
                    • S Simmania

                      I also found this one:

                      mTableView->setShowGrid(false);
                      

                      And it works!

                      With the stylesheets there may be much more control possible, but I have a hard time finding out which selection class to use en what the possible properties are.

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Simmania said in How can I hide the borders of the cells in a QTableView?:

                      mTableView->setShowGrid(false);

                      This is easier of course :-)

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • D davecotter referenced this topic on

                      • Login

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