Important: Please read the Qt Code of Conduct -

How to recognize padding for a QTableView table item?

  • For a column with an icon and text (left column), I need to calculate the fixed column width and set it in pixels (as the architect wants).

    The size of the icon is known, the size of the longest line of text in the column is also known and is calculated through fontMetrics (). Only the default padding used in the cell is unknown, and it is needed for calculations.

    I read the documentation, but I find only solutions "how to install padding":

    ui-> fingerTableView-> setStyleSheet ("QTableView :: item {padding: 25px}");

    But I need to do the opposite thing: how to get the default padding from the table cell.

    There is a styleSheet () method that returns a style, and I could parse it. But the problem is that this method actually returns just the style specified through setStyleSheet (), not the default style.

    Where else can I get the default padding for the table item, I can not figure it out. Help.

  • Lifetime Qt Champion

    @xintrea said in How to recognize padding for a QTableView table item?:

    not the default style.

    Only the stylesheet style provides a padding (see box model), all other styles don't have a 'padding' value at all. So what do you want exactly (and why)?