3

I'm wondering if it is possible to adjust the cell height of the attribute table (QGIS 2.14.3). I would like to reduce the cell height, to avoid the unused space in a cell.

enter image description here

underdark
  • 84,148
  • 21
  • 231
  • 413
Martin
  • 2,908
  • 4
  • 22
  • 44

1 Answers1

4

You can type the following in the Python Console to set the row height for each row in your Attribute Table:

from PyQt4.QtGui import QApplication, QTableView
layer = iface.activeLayer()
attrTables = [d for d in QApplication.instance().allWidgets() if d.objectName() == u'QgsAttributeTableDialog' or d.objectName() == u'AttributeTable' ]

for feat in layer.getFeatures():
    attrTables[0].findChildren(QTableView)[0].setRowHeight(feat.id(), 20)

Note: it seems that the height is not saved as when you close and reopen the attribute table, the cell height is returned to its default value. The columns width however are saved.


Credit to @MatthiasKuhn for his answer to this post.

Joseph
  • 75,746
  • 7
  • 171
  • 282