Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to recognize padding for a QTableView table item?
QtWS25 Last Chance

How to recognize padding for a QTableView table item?

Scheduled Pinned Locked Moved Unsolved General and Desktop
paddingqtreeviewitemstyle
2 Posts 2 Posters 2.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    xintrea
    wrote on 3 Feb 2020, 12:28 last edited by xintrea 2 Mar 2020, 12:52
    #1

    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.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 3 Feb 2020, 14:05 last edited by
      #2

      @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)?

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1

      1/2

      3 Feb 2020, 12:28

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved