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

1 Answer 1


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.

  • 1
    Thank you for your answer Joseph! I was hoping that there is a permanent solution for this.
    – Martin
    Feb 3, 2017 at 11:07
  • @Martin - Most welcome! Hopefully there is in which case someone can post a final solution =)
    – Joseph
    Feb 3, 2017 at 11:11
  • 2
    I think that it's not implemented yet. I found this feature request, it should refer to your issue.
    – mgri
    Feb 3, 2017 at 11:23
  • 1
    @mgri - Great find! I should certainly think it does refer to this issue. Many thanks :)
    – Joseph
    Feb 3, 2017 at 11:28
  • @mgri Jep it seems like that this refers to the issue. I hope that they will fix it in an upcomming version
    – Martin
    Feb 3, 2017 at 12:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.