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. Draw separator between overlapping QTableviews
Forum Updated to NodeBB v4.3 + New Features

Draw separator between overlapping QTableviews

Scheduled Pinned Locked Moved Solved General and Desktop
qtableview
12 Posts 3 Posters 1.0k 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.
  • F Offline
    F Offline
    firen
    wrote on last edited by firen
    #1

    Hello,

    my class is derived from QTableview and is based on the "frozentableview"-example from https://doc.qt.io/qt-5/qtwidgets-itemviews-frozencolumn-example.html. But my version is a bit more complex (I can have frozen columns OR rows) and a there can bemultiple frozen rows/columns and not only 1.

    My question:
    I need an optical separator between the "frozen" part of the table and the normal table. it should be a line with a width of 5 pixel and it should be only visible in the sheet itself (not in the headers). Sorry difficult to describe...

    Has someone an idea what would be an easy solution for that?

    One idea is, that I just draw, after everything else is painted, the line from the QWidget which is the parent of them. But than I need to calculate the exact position of the start/end of the frozen table and after a resize have I have to recalculate it everytime and so on...

    Thank you!

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      a lazy way would be to make a overlay qframe line with 5 pixel thickness on top of tableview in void showEvent(QShowEvent *);
      Its location can be found easily.
      A better way would be to draw bottom or top border lines of all items in that row by overriding the paint event.

      F 2 Replies Last reply
      0
      • JoeCFDJ JoeCFD

        a lazy way would be to make a overlay qframe line with 5 pixel thickness on top of tableview in void showEvent(QShowEvent *);
        Its location can be found easily.
        A better way would be to draw bottom or top border lines of all items in that row by overriding the paint event.

        F Offline
        F Offline
        firen
        wrote on last edited by
        #3

        @JoeCFD I tried already your second suggestion.

        My problem, was that I am not able to paint on the middle of the grid, because the frozen view lays on top of the "normal" view and if I repaint the normal view border, one half of the border is hidden by the frozen view. and if i try that with the frozen view I can only paint one half of the Line because i cant paint over the borders of the Widget.

        JoeCFDJ 1 Reply Last reply
        0
        • F firen

          @JoeCFD I tried already your second suggestion.

          My problem, was that I am not able to paint on the middle of the grid, because the frozen view lays on top of the "normal" view and if I repaint the normal view border, one half of the border is hidden by the frozen view. and if i try that with the frozen view I can only paint one half of the Line because i cant paint over the borders of the Widget.

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          @firen can you paint both of them at the same time?

          1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            a lazy way would be to make a overlay qframe line with 5 pixel thickness on top of tableview in void showEvent(QShowEvent *);
            Its location can be found easily.
            A better way would be to draw bottom or top border lines of all items in that row by overriding the paint event.

            F Offline
            F Offline
            firen
            wrote on last edited by
            #5

            @JoeCFD I like the idea with the QFrame but I am not realy sure how to do that..

            https://doc.qt.io/qt-5/qframe.html I guess I would need the VLine version right? because I only need the separator on one side. But how would I determine which side?

            JoeCFDJ 1 Reply Last reply
            0
            • F firen

              @JoeCFD I like the idea with the QFrame but I am not realy sure how to do that..

              https://doc.qt.io/qt-5/qframe.html I guess I would need the VLine version right? because I only need the separator on one side. But how would I determine which side?

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #6

              @firen it will be on the top of qtreeview and is in the middle. Google about how to make an overlay widget.

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

                Hi,

                Just a wild guess but what about keeping the border in the stylesheet but fix them all to 0 except the one you want with 5px ?

                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
                • F Offline
                  F Offline
                  firen
                  wrote on last edited by
                  #8
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    What result did you get from my suggestion ?

                    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
                    1
                    • F Offline
                      F Offline
                      firen
                      wrote on last edited by
                      #10

                      Once again rescued by @SGaist :-)

                      1 Reply Last reply
                      0
                      • F Offline
                        F Offline
                        firen
                        wrote on last edited by
                        #11

                        The documentation about stylesheets is for me not the best one from qt .. nevermind

                        1 Reply Last reply
                        0
                        • F Offline
                          F Offline
                          firen
                          wrote on last edited by
                          #12
                          This post is deleted!
                          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