Results 1 to 5 of 5

Thread: Transparent QHeaderView

  1. #1
    Join Date
    May 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Transparent QHeaderView

    Hi,

    I want to have a transparent HeaderView by reimplementing the paintSection method.

    No Problem with stylesheet
    setStyleSheet("QHeaderView::section {border: none; background-color: transparent;} QHeaderView {border: none; background-color: transparent;}");

    But I have no idea how to do it in paintSelection.

    Please help me out.

  2. #2
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Transparent QHeaderView

    If I understood your requirement correctly then you should set your header height to zero, and start your table view just below the point from where your cell area starts.

    Or your transparent headers does anything which will not work in above case.

    Please describe your requirement and may be some trick will work here.

  3. #3
    Join Date
    May 2014
    Posts
    4
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Transparent QHeaderView

    I have a custom TableView that should have the header part.
    The TableView should have transparent background: the header- as well as the cell area.

    I am able to change the background color of the header part by subclassing the HeaderView class and reimplementing the paintSection method, but not to transparent.

    So far I use setStyleSheet method to have transparent header part. However, I am quite sure that there is a way or some trick to do that by reimplementing the paintSection of custom HeaderView class.

  4. #4
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Transparent QHeaderView

    Hi,

    If you will upload some screenshot then it will help to understand what exactly you are looking for.

    Thanks,

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Transparent QHeaderView

    However, I am quite sure that there is a way or some trick to do that by reimplementing the paintSection of custom HeaderView class.
    You might try changing the QPainter::CompositionMode. I think the real problem is probably that the QHeaderView clears the section rect and fills it with the background color before it calls paintSection() so anything that might have been there from whatever is underneath has been erased.

    You could try setting the QWidget property autoFillBackground to false when you create the QHeaderView instance (or retrieve it from the QTableView). This changes the default behavior (erase and fill with the background color) to do nothing. You may not need to derive a custom class from QHeaderView.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 27th April 2015, 11:36
  2. Replies: 0
    Last Post: 25th August 2010, 17:39
  3. Replies: 2
    Last Post: 31st May 2010, 11:57
  4. Non-transparent QWidget on semi-transparent parent
    By EuroElessar in forum Qt Programming
    Replies: 0
    Last Post: 29th August 2008, 16:20
  5. Transparent background on QLabel on transparent QWidget
    By codeslicer in forum Qt Programming
    Replies: 1
    Last Post: 13th February 2008, 02:10

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.