Assuming you are using qmake for your project:
One possible solution would be to create an intermediate "compiler" that first transforms the ui file to remove the geometry tag and that passes it to uic - this way you can at least automate the process of removing the geometry tags.
The code for the PRO-file would add a new compiler like this:
uiungeom_c.name = fix ui of ${QMAKE_FILE_IN}
uiungeom_c.input = RAW_FORMS
uiungeom_c.variable_out = FORMS
uiungeom_c.commands = /path/to/<some_command> ${QMAKE_FILE_IN} ${QMAKE_FILE_OUT}
uiungeom_c.output = ./.uifix/${QMAKE_FILE_BASE}.ui
uiungeom_c.CONFIG += target_predeps
QMAKE_EXTRA_COMPILERS += uiungeom_c
And change the FORMS
in your pro file to RAW_FORMS
, i.e.
RAW_FORMS += mainwindow.ui #...
This will run the <some_command>
on all your ui-files and generate a copy of them without the geometry in your build folder in a subfolder. Those generated ui files are automatically passed to the FORMS
variable and thus are now passed on to uic
to create the header.
The tricky part here is the <some_command>
- You would have to create some kind of script (bash, batch, python, XSLT-Transformation, ... - whatever you prefer) that takes the original xml file as input and removes the tag. XSLT-Transformations are propably the most elegant and reliable way, but also the most complicated - you can learn more about them at W3schools, but I would propably just use python, as it propably leads the the smallest and easiest to understand script.
(If you would like to see a basic sample in python that could do the job, I can fiddle one out later the day - just ask for it as a comment)