How can I change the appearance of the attribute table in QGIS, so that I can view the cell's font an its size smaller in my computer's screen?
Asked
Active
Viewed 411 times
1
-
Please ask your question in English in order to allow all users to answer it. – Erik Mar 05 '21 at 19:35
1 Answers
2
You should look at below code to change configuration. We copy a config file for column with for a particular layer. We choose to set for all columns a width of 250. By default, width = -1 (for auto size)
With this code, you can play to hide columns, change their orders, change their width, tell if they are a field column or an action column
layer = iface.activeLayer()
copy_columns = []
attributeTableConfig = QgsAttributeTableConfig()
# Plaything you can use to revert the order of column if used
# for i in reversed(layer.attributeTableConfig().columns()):
for i in layer.attributeTableConfig().columns():
colConfig = attributeTableConfig.ColumnConfig()
colConfig.hidden = i.hidden
colConfig.name = i.name # You may use this name to custom each col size depending of your knowledge of custom content in each column name
colConfig.type = i.type
colConfig.width = 250
copy_columns.append(colConfig)
attributeTableConfig.setColumns(copy_columns)
layer.setAttributeTableConfig(attributeTableConfig)
Old (only about fonts)
You may use the following content in a custom.qss file and load it as a new theme using plugin "Load QSS - UI themes"
QgsAttributeTableView, QHeaderView {
font-size: 8px;
}
You may look at QSS reference at https://doc.qt.io/qt-5/stylesheet-reference.html to learn more
Below an overview result before/after
ThomasG77
- 30,725
- 1
- 53
- 93
-
What about my cell's size?, Can I change it's size too with this plugin? – Zamir Esteban Cajamarca López Mar 05 '21 at 21:19
-
Updated answer with code (no need for the plugin except for fonts size, except if other people can recommend a better solution) – ThomasG77 Mar 05 '21 at 22:25

