Search code examples
pythonxmlqtpysideqt-designer

Does Qt Designer or associated Qt tool have a global find-and-replace functionality for the xml formatted *.ui files?


My specific problem right now is relates to a roughly 4,800 line .ui file that I’ve created in Qt Designer in which I need to do some basic refactoring (renaming widgets). I convert the .ui file to a python file via pyside-uic. I’ve gone over the Qt Designer documentation enough to convince myself with 95% certainty that it is not possible to do a global find-and-replace of widget names, or parts of names, from within Qt Designer itself. For example:

Step 1) Find 'pushButton'
Step 2) Replace with 'btn'
Step 3) Result is, i.e., 'pushButtonFooBarFooBar' gets renamed 'btnFooBarFooBar'

My first hope lies in that remaining 5% uncertainty from my document search of Qt Designer. If I’ve missed something that provides this functionality I will be elated. And I will abandon looking at more elaborate solutions using scripts and/or text editors. In the big picture, had I better planned my naming scheme about 4,800 lines of code ago I wouldn’t have this problem now.

So my question, simply put, is:

Is there a global find-and-replace functionality within Qt Designer or associated Qt tools, and if so how is it invoked?


Solution

  • Is there a global find-and-replace functionality within Qt Designer or associated Qt tools, and if so how is it invoked?

    No. But since XML is a text file, you are more than welcome to do a text search-and-replace in your favorite editor. E.g. using regexps replace "pushButton([a-zA-Z0-9_$]*)" with "btn$1".

    Unfortunately, Qt Creator doesn't offer a regexp capture replace function, but other editors surely do.