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. Rerectangle around a single row in QTableWidget
Qt 6.11 is out! See what's new in the release blog

Rerectangle around a single row in QTableWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 641 Views 2 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.
  • B Offline
    B Offline
    Buller
    wrote on last edited by
    #1

    What is the best way to draw a rectangle around a single row in QTableWidget? All searches lead me to QTableView and delegates. My main problem is that I am not able to find the geometry of the area to draw. I have tried obtaining the geometry of the cell widgets, thus:
    int x = m_pTableWidget->cellWidget(0,i)->width();
    but that down not work.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      In what conditions do you want to draw that rectangle ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      B 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        In what conditions do you want to draw that rectangle ?

        B Offline
        B Offline
        Buller
        wrote on last edited by
        #3

        @SGaist I want to draw a rectangle around the top row and it should be there permanently. So I can do it in the constructor.

        mrjjM 1 Reply Last reply
        0
        • B Buller

          @SGaist I want to draw a rectangle around the top row and it should be there permanently. So I can do it in the constructor.

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

          @Buller
          Hi
          Maybe you can reuse my test delegate from
          https://forum.qt.io/topic/112854/qtablewidget-replace-dotted-selected-row-with-border/2

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Row number 0 or the one that is currently show the closest to the header ? If the later then QRubberBand might also be of interest.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            B 1 Reply Last reply
            0
            • SGaistS SGaist

              Row number 0 or the one that is currently show the closest to the header ? If the later then QRubberBand might also be of interest.

              B Offline
              B Offline
              Buller
              wrote on last edited by
              #6

              @SGaist Yes, it is. The problem I have is that I cannot find the rectangle I want to draw around. I looked at
              mrjj 's solution above, but that seems to involve a delegate. What is the "option" in:
              const QRect rect( option.rect );

              SGaistS 1 Reply Last reply
              0
              • B Buller

                @SGaist Yes, it is. The problem I have is that I cannot find the rectangle I want to draw around. I looked at
                mrjj 's solution above, but that seems to involve a delegate. What is the "option" in:
                const QRect rect( option.rect );

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                @Buller it's explained in the QStyledItemDelegateOption documentation.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0

                • Login

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