Qt Creator - How to keep a .ui file open in Design mode, and a different file open in Edit mode?
-
My project has one .ui file (just one window), but the C++ code is divided into lots of different source files. I often want to edit some code, then quickly switch to design mode to edit the single GUI for my project, then go back to editing code.
Here is the process I've been reluctantly following:
- edit some source or header file
- I see some need to edit the .ui file. I have to go to the Project sidebar and look for the .ui file then double click it and enter Design mode
- after finishing the modifications that were needed, I then click Edit mode to go back to editing code, with the goal of editing the same C++ file I was editing previously
- Doing so makes Qt Creator think that I'm trying to directly edit the XML code for the .ui file, and so switches to the XML code and says the warning "This file can only be edited in Design mode" (yeah, OK, I know that, I'm not trying to edit the .ui file bro)
- then I have to remember which file I was editing before, search for it and click on it in the Projects sidebar
- I realize again something I need to look at or change on the GUI, so I repeat this process again - look for the .ui file, double click it to do some stuff in Design mode, go back to Edit mode, get the warning, and click back on the source file
I've found a few alternatives that are still not ideal, such as:
- use shift+F4, which opens the .cpp file for the GUI in Edit mode
- This is really not ideal because I often don't want to edit the .cpp file for the GUI and have some other file in mind, or had some other file opened before switching to Design mode
- If I am not currently editing the GUI's source file (say the GUI's header file), then Shift+F4 to go to Design mode does nothing.
- Use Ctrl+Tab to cycle through the files I have open
- this is also not ideal because I have to Ctrl+Tab through the recently edited files until the .ui file is highlighted, then I can go into Design mode. This can take me a while to do when I have lots of files open, I've edited more than one file since being in Design mode, and I had little sleep the night before on top of an annoying condition called ADHD; so cycling through a file list makes me forget which file I was trying to open and my concentration is about to receive the kiss of death
- not to mention that the number of times I have to press Ctrl+Tab to get to the .ui file is not a constant. It could be 1 time, 2 times, 3 times, 7 times, etc...this can break my very brittle concentration
Here is what I oh-so-wish were possible:
- edit some source or header file
- I see some need to edit the .ui file. I press a keyboard shortcut to go to Design mode, where the single GUI I am designing is open and waiting for me
- after finishing the modifications that were needed, I press a keyboard shortcut to go to Edit mode, where the C++ file I was editing previously is patiently waiting for me
Is this possible to do? Am I missing some important setting in Options or does some keyboard shortcut I haven't found do what I've described?
Any help will be greatly appreciated!
-- Never-Productive-Enough ADHDer
-
I have a not-so-good workaround for this: Qt Creator lets you open several windows, but opens Design Mode in only one of them.
Look for the split icon (top-right on any code editing view), click it and select "Open in New Window". Then you can keep editing your source code in one window and have the editor opened in the other. This works best if you have multiple monitors or one big one.
-
I hope I'm allowed to post here just to grumble :) This has bothered me too in Creator, but I just thought I'd better hold my peace.
I'm a great fan of Qt, but Creator is just that horrible, overused word --- "clunky" :( I do however realise that, say, MS Visual Studio probably had 1,000 people working on it with an unlimited budget, while Creator (by the looks of it) no longer has had even one person in years!
Inevitably we will swap between Design button and Edit button to go edit a code file. It drives me mad that I get put into the This file can only be edited in Design mode. Given that I'm not allowed to edit the XML, find a way of not putting me there!
While we are on that subject. Can we please have a I know what I'm doing, can you let me edit the bloody XML button next to the Switch Mode? There are plenty of cases where you need, or it's easiest, to edit the XML --- just for example, hunting down all those inline stylesheets, finding/changing any font sizes, and so on. Even in this forum there are times we are told to go edit the
.ui
file to achieve something. How are we supposed to be able to do that? Only two ways: go edit it in an external, non-XML-aware text editor, or copy it to a.xml
, make edits, copy it back to.ui
. Since Creator allows you to edit the.ui
externally and re-read it, it might as well offer an "advanced" option to allow it that from within.This works best if you have multiple monitors or one big one.
When Qt comes supplied with a larger or spare monitor I will welcome your suggestion. Till then I only have my one 1920x1200.... :)
after finishing the modifications that were needed, I press a keyboard shortcut to go to Edit mode, where the C++ file I was editing previously is patiently waiting for me
I don't know whether you have noticed this, but if you go Ctrl+Tab once, don't bother looking at the list of filenames, and just release, you alternate between this and the previous file. So once you have gotten going on a
.ui
plus its corresponding.cpp
/.h
this does count as your desired keyboard shortcut?Thanks for listening :)
-
@chimpdude said in Qt Creator - How to keep a .ui file open in Design mode, and a different file open in Edit mode?:
after finishing the modifications that were needed, I press a keyboard shortcut to go to Edit mode, where the C++ file I was editing previously is patiently waiting for me
When you're finished with your modification in design mode:
STRG + S to save changes
STRG + W to close design file and to go back to the previous file -
@JonB said in Qt Creator - How to keep a .ui file open in Design mode, and a different file open in Edit mode?:
I hope I'm allowed to post here just to grumble :)
+1 no problem :-)
I'm a great fan of Qt, but Creator is just that horrible, overused word --- "clunky" :( I do however realise that, say, MS Visual Studio probably had 1,000 people working on it with an unlimited budget, while Creator (by the looks of it) no longer has had even one person in years!
Check QtC changelog - there's usually at least 10-20 people contributing to each release. I don't know how many people work on QtC full-time, though. My guess is 2-5 people.
Inevitably we will swap between Design button and Edit button to go edit a code file. It drives me mad that I get put into the This file can only be edited in Design mode. Given that I'm not allowed to edit the XML, find a way of not putting me there!
This is actually pretty easy, although a bit hidden (that's bad!). Right click on
file name -> Open With -> Plain Text Editor
. Voila, you can edit the XML.This works best if you have multiple monitors or one big one.
When Qt comes supplied with a larger or spare monitor I will welcome your suggestion. Till then I only have my one 1920x1200.... :)
I strongly suggest getting something bigger. 1440p or 4K monitor is a real breath of fresh air. And 2+ monitors help a lot, too. Monitors are pretty cheap these days.
(this, of course, in no way is an excuse for Qt Creator :D Just a general recommendation)
after finishing the modifications that were needed, I press a keyboard shortcut to go to Edit mode, where the C++ file I was editing previously is patiently waiting for me
I don't know whether you have noticed this, but if you go Ctrl+Tab once, don't bother looking at the list of filenames, and just release, you alternate between this and the previous file. So once you have gotten going on a
.ui
plus its corresponding.cpp
/.h
this does count as your desired keyboard shortcut?Hey that's cool!
-
@sierdzio said in Qt Creator - How to keep a .ui file open in Design mode, and a different file open in Edit mode?:
Check QtC changelog - there's usually at least 10-20 people contributing to each release.
Oh I get that. But I meant: I don't see much activity on Qt Designer, any longer.
This is actually pretty easy, although a bit hidden (that's bad!). Right click on file name -> Open With -> Plain Text Editor. Voila, you can edit the XML.
Ooohhh! That helps a lot, thank you! The form is then blank if you go Design. Now all I want is some kind of: when in Design mode edit as Form, when in Edit mode edit as XML, without having to swap the Open with... all the time :)
-
@JonB said in Qt Creator - How to keep a .ui file open in Design mode, and a different file open in Edit mode?:
This is actually pretty easy, although a bit hidden (that's bad!). Right click on file name -> Open With -> Plain Text Editor. Voila, you can edit the XML.
Ooohhh! That helps a lot, thank you! The form is then blank if you go Design. Now all I want is some kind of: when in Design mode edit as Form, when in Edit mode edit as XML, without having to swap the Open with... all the time :)
Here, unfortunately, I have no answer :-( it annoys me as well, although not in this case (I rarely use .ui files) but for QRC files.