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 customize movable header shadow
Forum Updated to NodeBB v4.3 + New Features

How to customize movable header shadow

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 297 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.
  • C Offline
    C Offline
    Cybernetter
    wrote on last edited by Cybernetter
    #1

    Hello,

    In my application I have reimplemented QHeaderView in order to design a 45 degree angled header for a table which (after a lot of struggles) works quite well, and it looks like this:
    2021-12-15 14_07_20-.png

    The only issue I have with it is something I haven't been able to find anywhere. Whenever I drag a column, the 'shadow' that moves with the mouse still remains the same default header section design. Here is a picture (I am referring to the gray rectangle):

    2021-12-15 14_12_00-.png

    I have no idea what kind of component/element that is, and how to change it. Qt documentation tells me nothing, as far as I read...
    I am also using PyQt 6.

    Any ideas would be very appreciated. Thank you.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      The pixmap is created inside QAbstractItemViewPrivate::renderToPixmap() by calling the delegate for each index. So provide a custom item delegate where paint() returns your pixmap

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      C 2 Replies Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        The pixmap is created inside QAbstractItemViewPrivate::renderToPixmap() by calling the delegate for each index. So provide a custom item delegate where paint() returns your pixmap

        C Offline
        C Offline
        Cybernetter
        wrote on last edited by
        #3

        @Christian-Ehrlicher

        Thank you! I will try that today.

        Have a good day :)

        1 Reply Last reply
        0
        • Christian EhrlicherC Christian Ehrlicher

          The pixmap is created inside QAbstractItemViewPrivate::renderToPixmap() by calling the delegate for each index. So provide a custom item delegate where paint() returns your pixmap

          C Offline
          C Offline
          Cybernetter
          wrote on last edited by
          #4

          @Christian-Ehrlicher It seems like QHeaderView does not support setItemDelegate.
          From Qt docs: Note: Each header renders the data for each section itself, and does not rely on a delegate. As a result, calling a header’s setItemDelegate() function will have no effect.

          What am I missing? Right now I am reimplementing paintEvent to change the header appearance. Can I do something there?

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #5

            You're right - I took the wrong place. The pixmap is created via QHeaderView::paintSection() (via QHeaderViewPrivate::setupSectionIndicator() and QHeaderView::mousePressEvent()) which is virtual so you should be able to override it.

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            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