Results 1 to 4 of 4

Thread: QTableview with flat header

  1. #1
    Join Date
    Apr 2013
    Posts
    63
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default QTableview with flat header

    I want to create a table with minimum space use. When I reduce the row size to minimum, the text in headers are not visible clearly as it has 3D shading. Other cells are fine with this row height as they are flat. Is there a way to make the Headers of the table Flat? After making headers FLAT, I Also need to change the header background to a different color. Advanced thanks for sample code for both

  2. #2
    Join Date
    Oct 2012
    Posts
    21
    Thanks
    1
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableview with flat header

    How about using styles? Applying any custom style to a widget immediately kills all the default visual effects. So doing something like this:

    Qt Code:
    1. myTableWidget.setStyle("QHeaderView::section { border: 1px solid black}")
    To copy to clipboard, switch view to plain text mode 


    will give you tiny flat header. More info here

  3. The following user says thank you to AlexVhr for this useful post:

    mqt (22nd June 2013)

  4. #3
    Join Date
    Apr 2013
    Posts
    63
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableview with flat header

    setStyle helped. But still the header view looks slightly different than other cells. Is there a way to exactly replicate the style of Other cells to header?

  5. #4
    Join Date
    Oct 2012
    Posts
    21
    Thanks
    1
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTableview with flat header

    Ah, so you are aiming for a maximum resemblance with the other cells. Then maybe try this style:

    Qt Code:
    1. QHeaderView::section {
    2. border-top: 0px solid grey;
    3. border-bottom: 1px solid grey;
    4. border-right: 1px solid grey;
    5. background:white;}
    To copy to clipboard, switch view to plain text mode 

    You can experiment with styles in QtDesigner, by the way.

  6. The following 2 users say thank you to AlexVhr for this useful post:

    aliks-os (22nd January 2015), mqt (23rd June 2013)

Similar Threads

  1. QTableView header invisible
    By smacchia in forum Qt Programming
    Replies: 7
    Last Post: 20th November 2009, 03:21
  2. QTableView with fixed header
    By aLiEnHeAd in forum Qt Programming
    Replies: 1
    Last Post: 25th November 2008, 08:14
  3. QTableView header dragging
    By cmaxb in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2006, 12:11
  4. QTableView header in corner
    By danstr in forum Qt Programming
    Replies: 3
    Last Post: 18th May 2006, 20:16
  5. QTableView: disable row header
    By mattie in forum Qt Programming
    Replies: 6
    Last Post: 8th March 2006, 12:16

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.