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 alter perimeter around a QTableWidget cell?
Forum Update on Monday, May 27th 2025

How to alter perimeter around a QTableWidget cell?

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 491 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on last edited by
    #1

    If I want to add a bottom border line, or a left, right, or top border line, is that possible with a cell in a QTableWidget?

    JonBJ 1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      Well using a delegate , you can draw the text your self and also
      extra lines, however, you have to also control the editing as for it to not break
      when going into edit mode.

      https://forum.qt.io/topic/117896/conditional-borders-on-qtablewidget-cells

      1 Reply Last reply
      1
      • P Publicnamer

        If I want to add a bottom border line, or a left, right, or top border line, is that possible with a cell in a QTableWidget?

        JonBJ Offline
        JonBJ Offline
        JonB
        wrote on last edited by JonB
        #3

        @Publicnamer
        I don't know what @mrjj thinks, and whether this would avoid the editing issue, but you could also do it from stylesheet via

        QTableView::item {
            border-top/right/bottom/left: 1px solid red;
        }
        

        But this is easiest if you want to change all cells' borders, not so much if you want to be selective.

        P 1 Reply Last reply
        2
        • JonBJ JonB

          @Publicnamer
          I don't know what @mrjj thinks, and whether this would avoid the editing issue, but you could also do it from stylesheet via

          QTableView::item {
              border-top/right/bottom/left: 1px solid red;
          }
          

          But this is easiest if you want to change all cells' borders, not so much if you want to be selective.

          P Offline
          P Offline
          Publicnamer
          wrote on last edited by
          #4

          @JonB It seems like a lot of processing to have an interpreter parse a style sheet. Isn't there a more native, C++ way to set the borders?

          JonBJ 1 Reply Last reply
          0
          • P Publicnamer

            @JonB It seems like a lot of processing to have an interpreter parse a style sheet. Isn't there a more native, C++ way to set the borders?

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by
            #5

            @Publicnamer said in How to alter perimeter around a QTableWidget cell?:

            It seems like a lot of processing to have an interpreter parse a style sheet.

            Seriously? Qt widgets has stylesheets, with its interpreter, used in hundreds/thousands(?) of applications. It's what I would use for choice rather than writing code. But entirely up to you. If you do want to write some C++ code to do the job you have @mrjj's suggestion to pursue.

            P 1 Reply Last reply
            2
            • JonBJ JonB

              @Publicnamer said in How to alter perimeter around a QTableWidget cell?:

              It seems like a lot of processing to have an interpreter parse a style sheet.

              Seriously? Qt widgets has stylesheets, with its interpreter, used in hundreds/thousands(?) of applications. It's what I would use for choice rather than writing code. But entirely up to you. If you do want to write some C++ code to do the job you have @mrjj's suggestion to pursue.

              P Offline
              P Offline
              Publicnamer
              wrote on last edited by
              #6

              @JonB Yes seriously. Of course seriously. A good engineer always designs code to run well on slow computers. Interpreters are frequently bulky memory hogs that cause computers to slow down.

              mrjjM 1 Reply Last reply
              0
              • P Publicnamer

                @JonB Yes seriously. Of course seriously. A good engineer always designs code to run well on slow computers. Interpreters are frequently bulky memory hogs that cause computers to slow down.

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                Hi
                Premature optimization is also a topic you should consider.

                Stylesheets are not inherently slow but if overused can become heavy.
                They are parsed on load and values are set to internal structures used by QStyle.
                So its not Interpretered over and over.

                1 Reply Last reply
                2

                • Login

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