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.
Asked
Active
Viewed 839 times
1 Answers
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.
-
1Thank you for your answer Joseph! I was hoping that there is a permanent solution for this. – Martin Feb 03 '17 at 11:07
-
@Martin - Most welcome! Hopefully there is in which case someone can post a final solution =) – Joseph Feb 03 '17 at 11:11
-
2I think that it's not implemented yet. I found this feature request, it should refer to your issue. – mgri Feb 03 '17 at 11:23
-
1@mgri - Great find! I should certainly think it does refer to this issue. Many thanks :) – Joseph Feb 03 '17 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 03 '17 at 12:33
-
Are there a good solution for QGIS 3.16 ? – Jürgen Aug 11 '21 at 13:57
-
Related : https://stackoverflow.com/questions/29259923/pyqt5-cannot-import-name-qapplication – Taras May 18 '22 at 08:57
