I use custom Qt widgets like QgsMapLayerComboBox for my QGIS plugin, laying the whole thing out in Qt Designer. Using those requires fixing headings in .ui file as described here. Unfortunately I have to fix headers every time I save my .ui file.

So the question is: is it possible to make Qt Designer reference qgis.gui headers by default?


I think it's not possible IIRC, it's a bug reported.

I have wrote this script for myself:

if [ $# -eq 1 ]
    sed -i.bak -e 's|<header>.*</header>|<header>qgis.gui</header>|g' $1
    rm $1.bak
    echo "Usage: fix_widgets_ui.sh ui_file.ui"


  • Thanks! Do I have to manually launch this every time I save the .ui? p.s. I'm using windows
    – Basile
    Oct 28 '17 at 14:21
  • 1
    Yes, I don't know if you can launch it automatically after each save. The script it's compatible (no GNU or BSD sed specific) with *BSD, linux and OS X. I haven't tested with windows. I think it sould be run with OSGEO4W installation (msys) Oct 30 '17 at 4:36

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.