Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Search and replace across source and ui files



  • I noticed some widgets in a ui file are not named correctly, and wanted to correct that. Since the current names are already used in source files, the safest way seemed to be the Advanced Search & Replace feature of Qt Creator (2.4.1)

    However, it seems that while the .ui file is displayed in the list of search results, the replace does not affect the ui file.

    How can I make the Search & Replace affect the ui file also?



  • The ui file is officially only editable through the designer. If you want to change strings in those as well, you'll have to either rename the files for this purpose, or do the replace using sed or awk or any other program that doesn't care about the actual contents of the file.



  • Then I guess "Rename symbol under cursor" won't work, either.



  • I haven't but you can try and see what happens. Worst thing that can happen is that you have to undo it.


  • Moderators

    Please consider "filing a bug report":http://bugreports.qt-project.org/ .



  • Sometimes it is annoying that the files are only editable through designer, as some things are easier to do directly in the file. And of course because Designer creates files that cause warnings by uic during compilation...



  • [quote author="Andre" date="1331026838"]Sometimes it is annoying that the files are only editable through designer, as some things are easier to do directly in the file. And of course because Designer creates files that cause warnings by uic during compilation...[/quote]

    Just right-click on the ui file in the project tree and select "Open with..." and then "Plain Text Editor".

    PS:
    If you double click on a .ui file it opens in designer mode by default. If you don't close it with ctrl-w, but just hit ESC, you're in a plain text editor with the XML too.



  • The editor you get when pressing ESC is read-only for me, but the right-click approach gives me an editable XML representation. It does not work for already open files in the open files list, but it works for the project tree. Thanks for the tip!



  • Posted a bug report:

    https://bugreports.qt-project.org/browse/QTCREATORBUG-7044

    PS:

    bq. If you double click on a .ui file it opens in designer mode by default. If you don’t close it with ctrl-w, but just hit ESC, you’re in a plain text editor with the XML too.

    Not an editor. Just a viewer. I can't change anything there.


Log in to reply