Advertisements

Smaller Toolbar Icons for QGIS

Do you have a small resolution screen and want to use QGIS? Then you know the problem of toolbars using up precious screen estate.

In QGIS 1.7

You find the option to make icons smaller (16×16) or bigger (32×32) in the options dialog:

Options dialog with icon size option

If you are running a version of QGIS < 1.7

You can change the size of toolbar icons to any value you like – smaller or bigger than by default. And this is how it’s done (in Python console):

from PyQt4.QtGui import QToolBar
from PyQt4.QtCore import QSize

toolbars = qgis.utils.iface.mainWindow().findChildren(QToolBar)
for toolbar in toolbars:
    toolbar.setIconSize(QSize(16,16))

All toolbar icons will be scaled down to 16×16 pixels.

Kudos to Webrian on forum.qgis.org for this tip and to Nathan for pointing out how to access all toolbars.

Advertisements
9 comments
  1. Kurt said:

    Great tip!
    thanks, can this tip be made permanent ?? When I restart qgis the icons are reset to default-size…

    • underdark said:

      Hi Kurt,
      I wrote a quick and dirty plugin that scales all accessible toolbar icons to 16×16. I can mail it to you if you want.

      • Kurt said:

        Hi underdark,

        yes please email me yout plugin

        thanks

        Kurt

  2. Good tip. One thing however, this won’t scale any toolbars that are made by plugins eg GRASS plugin toolbar. What you can do however is something like this:

    from PyQt4.QtGui import QToolBar
    from PyQt4.QtCore import QSize

    toolbars = qgis.utils.iface.mainWindow().findChildren(QToolBar)
    for toolbar in toolbars:
    toolbar,setIconSize(QSize(16,16))

    This will loop all the toolbars in the QGIS window and set there icons to 16 x 16.

    • underdark said:

      Thanks Nathan! That’s great!

      Much better than having to call the toolbars by name. I’ll update my post.

      • Nathan said:

        Good news. I sent a patch in a day ago to allow the user to set the size (16,24,32) in the options dialog, and Garry committed it to trunk so the options will be there in v1.7. :)

      • underdark said:

        That’s great! Thanks for sharing!

  3. cathy said:

    Hi underdark,
    can you also mail me that plugin

    thanks in advance

    cathy

    • underdark said:

      Please install 1.7, then you don’t need a plugin to do this. The functionality has been added to QGIS main application.

%d bloggers like this: