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 make vertical header of QTableWidget resizable by mouse?
Forum Updated to NodeBB v4.3 + New Features

How to make vertical header of QTableWidget resizable by mouse?

Scheduled Pinned Locked Moved General and Desktop
qtablewidgetqheaderview
10 Posts 3 Posters 7.0k 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.
  • asmirnA Offline
    asmirnA Offline
    asmirn
    wrote on last edited by asmirn
    #1

    I need to make vertical header of QTableWidget resizable by mouse like sections. I also want to make the same reaction for double click. How can I do this?

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

      Hi and welcome to devnet,

      When double clicking a section you'll have sectionDoubleClicked emitted. With that you can trigger a resize on the corresponding section.

      Hope it helps

      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
      • asmirnA Offline
        asmirnA Offline
        asmirn
        wrote on last edited by asmirn
        #3

        When double clicking a section you'll have sectionDoubleClicked emitted. With that you can trigger a resize on the corresponding section.

        I am talking about behaviour when cursor is under splitter between vertical header column and section column. If left mouse button is pressed and mouse move than resizing is need. Double click - auto resizing.

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

          So that would be sectionHandleDoubleClicked

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

          asmirnA 1 Reply Last reply
          0
          • SGaistS SGaist

            So that would be sectionHandleDoubleClicked

            asmirnA Offline
            asmirnA Offline
            asmirn
            wrote on last edited by asmirn
            #5

            So that would be sectionHandleDoubleClicked

            I am talking about vertical header resizing. Not about sections resizing. And primary problem is resizing by mouse moving when left mouse button is pressed I want to make cursor as resizing cursor when it is under splitter between vertical header and first section. Than if left mouse button is pressed mouse moving resizes vertical header width. I want exactly same behaviour like for sections.

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

              The vertical and horizontal header view follow the same logic. I might misunderstand you, can you show a picture how what you would like to achieve ?

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

              asmirnA 1 Reply Last reply
              0
              • SGaistS SGaist

                The vertical and horizontal header view follow the same logic. I might misunderstand you, can you show a picture how what you would like to achieve ?

                asmirnA Offline
                asmirnA Offline
                asmirn
                wrote on last edited by asmirn
                #7

                Alt text
                I need to make vertical header resizeable by mouse when cursor is between vertical header and first section.

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

                  Did you set the ResizeMode ?

                  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
                  • asmirnA Offline
                    asmirnA Offline
                    asmirn
                    wrote on last edited by asmirn
                    #9

                    Did you set the ResizeMode ?

                    I'm talking about resizing of vertical header width not about sections. With sections all is well.

                    Alt text
                    This is what do I need.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      karlheinzreichel
                      wrote on last edited by karlheinzreichel
                      #10

                      Hi asmirn
                      I think I have a solution regarding your question.

                      You have to implement the resize mechanism by yourself as the QTableView / QHeaderView will not support the resizing by itself.

                      The way i did:

                      First derive a subclass from QHeaderView (e.g. VerticalHeaderView) and override the mousePressEvent / mouseMoveEvent / mouseReleaseEvent, to get the relevant mouseclicks mousemove-positions for the headerview.

                      Then if the user clicks the left mouse button in a certain distance to the left VerticalHeaderView border you can start
                      resizing the VerticalHeaderView with setFixedWidth(newWidth).
                      Do not forget to tell the according QTableView/QTableWidget about the resizing by calling updateGeometries() for the QTableView/QTableWidget.

                      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