How to set the padding of QTableView cells through CSS?


Tags: c++,css,qt

Problem :

Is it possible to define the padding of QTableView cells? I would expect this to be possible using CSS stylesheets, but the documentation does not describe a method to do this.

The following stylesheet does not have the desired effect:

QTableView {
  padding: 5px;
}

as it influences the padding property of the widget as a whole, not of the individual cells.



Solution :

I know this is an old question but I've been struggling with this recently.

I found out that by setting

tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);

the padding set in your CSS will then be applied to the top and bottom of the cell, too!


    CSS Howto..

    How to make flash movie to scale proportunatly to div width?

    How to create a medal in css [closed]

    How to create a Vertical Strikethrough in CSS?

    How to keep top of element static while bottom is dynamic. -CSS

    how to css absolute positioning right way

    How do I keep my footer at the bottom of the page without it coming up automatically to fill space if there is little content?

    How get dimension of HTML shadow element via JavaScript

    How to add composite css -webkit-mask-image?

    How to change 'inherited' font families using the CSS style sheet

    How to add multiple css rules to minimize browser reflows?

    How can I translate with webkit-transform enough so that

    How I can add td to css style for inputs and its label?

    how to create a QT plugin using Meego Touch Framework?

    How to place circle and text in one line?

    Is it possible to have a web browser scroll to show CSS fixed position items that are outside the viewport of the web browser?

    How to hide the “body” statement in css and javascript

    How to keep image lumpted with last word in a paragraph

    “show/hide” a div with javascript not jquery, and not with display:none

    how to route arrow from right to down css

    How to make a website run faster?

    How to style differently only the first list item from unsorted list

    How do i make the evenly spread elements in my nav bar not touch the edges of the page?

    How to align nav bar to bottom of window with no gap between buttons and window edge

    How to create header numbers with CSS

    How to change css classes with a button click in javascript?

    Dompdf: how to get background image to show on first page only

    jQuery - How to adjust CSS filter (blur)?

    How to correctly wait until JavaScript applies inline Css

    How to create CSS-based (big) quotation marks?

    How do I mask a region of the page in a responsive design using CSS?