qtclion

Open .ui File in CLion - Temporarily Ignore File Association


I am using CLion for Qt development on an Ubuntu 24.04 machine. I have associated .ui files with QT Designer, and I use that most of the time when building UIs so that's the way I would like to keep it.

But I occasionally have a need to edit the xml of the .ui files. Currently I do this by opening it in nano and editing, but I'm wondering if there is a way to open the xml file in CLion?

So, is there a way to open the .ui files in CLion, without changing the file associations? For example a menu item somewhere that says "Open With CLion" or similar thingy? (I couldn't find one so far though).

I have looked at issues here at SO and Jetbrain's YouTrack, but all of them seem to be about changing file association, or file associations not working etc. I haven't found any guidance about how to open a .ui file in CLion, while still preserving the file association for Designer.

Hope the question is clear enough :)


Solution

  • I achieve this by using the IdeaVim plugin, via the command :e xxx.ui.

    This can only be considered a tricky way to get the job done, and I don't know if there are any other ideas for a solution.

    If you don't know Vim, I suggest you learn it.

    1. Install IdeaVim plugin in CLion.
    2. Enter normal mode (which is an editing mode unique to vim), the cursor display resembles a square instead of a vertical line.
    3. Type ":" to enter command mode (also unique to Vim), then type "e xxx.ui" to open the .ui file in CLion.

    The final realization is similar:

    final realization

    It is important to note that the following commands were added separately by me, in fact you can open any file by typing the above commands to open the .ui file.