tags:

views:

450

answers:

2

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.

+1  A: 

Yes it is possible with CSS-Stylesheets as you can see on that page full of examples.

Berschi
That page does not mention how to set the padding of the QTableView cells. Setting the padding on the QTableView influences the padding of the entire widget, not of the individual cells.
Ton van den Heuvel
+1  A: 

I managed to get it to work using the ::item sub-control specifier as follows:

QTableView::item
{
  border: 0px;
  padding: 5px;
}

Note that setting the border property here is necessary to get this to work. Also, this is not super ideal, since it only seems to influence the left and right padding of the QTableView cell. I can live with it for now though.

Ton van den Heuvel
Does anyone know why the 'border: 0px;' is required to make this work?
Krsna