11

When I open QGIS, the Layers Panel defaults to a width that doesn't show the "Remove Layer/Group" button. So I have to resize the panel to show the button every time I open QGIS.

Is it possible to set a default width for this panel so I don't have to resize it?

I am using QGIS 2.18.5 on Windows 10.

  • I add another panel (in my case Advanced Digitizing Tool or Value Tool). Some of these panels try to keep their width. But I agree, would be nice if a default width can be set. – Kazuhito Apr 28 '17 at 5:30
  • It would be nice for the project to remember, but you don't need that button as the function is available via the layer-right-click popup menu, so there's no need to resize (i.e. it's exactly the same number of button clicks - one on the layer and one to remove). If you still want to use the button, you still don't need to resize as you can click the >> button at the edge of the pane and any hidden buttons appear in a popup (this applies to all QGIS menus). – MappaGnosis Apr 28 '17 at 7:02
11

Using a bit of Python, we could create a startup.py script which sets the width of the layers panel by using the following:

from qgis.utils import iface
from PyQt4.QtGui import QDockWidget

for x in iface.mainWindow().findChildren(QDockWidget): 
    if x.objectName() == 'Layers':
        x.setFixedWidth(250)
        x.setMinimumWidth(100)
        x.setMaximumWidth(1000)

Save the script in your /.qgis2/python/ directory. Now whenever you load QGIS, the width of the layers panel will be set accordingly.

  • 1
    Thank you Joseph this is a good solution. However I did find that setting a lower minimumWidth after the fixedWidth made the fixedWidth redundant. So for my purposes I only used x.setMinimumWidth(250), 250 was the magic number for me, this still allowed me to make the panel wider if needed. – balex May 1 '17 at 0:08
  • @balex - Most welcome, glad it helped! Funny, when I remove setFixedWidth, it doesn't resize accordingly. Perhaps because I'm using 2.18.2 but atleast it works for you :) – Joseph May 3 '17 at 9:11
9

For reference: there is Bug report #15479 Layers panel does not remember size which is related to your issue.

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.