Can I change the width of the drop-down field (attribute) list in the attribute table that is used for editing, i.e. the highlighted drop-down in the image below with the value "ID"
? The list is so narrow I can't see field names easily.
QGIS – Editing Width of Drop Down Field List in Attribute Table
attribute-tabledropdownlistpyqgisqgiswidth
Best Answer
There is a PyQGIS solution I can suggest. Honestly, it was tricky, and not straightforward.
The thing you are looking for is the
QFrame
hidden underAttributeTable / mUpdateExpressionBox / mFieldCombo
. It has a corresponding method for that calledsetFixedWidth()
.Let's assume there is a point layer with an opened attribute table in edited mode, see the below:
The default width of this drop-down list is 100, possible to see by means of the
width()
method.Proceed with
Plugins > Python Console > Show Editor
and paste the script below:Change the name of your input layer. Press
Run script
and get the output that will look like this:Now the new width is 500.
This solution will work as long as you keep your attribute table open, does not matter if it will be edited multiple times.
Perhaps, there is more easier way to exist.
P.S. I would appreciate it if someone could try this code.
References: