In QT Creator, I can rename functions, variables, enums, constants etc. by using refactor. It's global refactor.
But in Eclipse, I can only rename the name of the things inside just one file.
If I want to rename a function inside a source file, then I need to manually rename it inside the header file as well. But in QT Creator, I don't need to do that. It doesn't matter if the function is included inside other header file. QT Creator will find it and rename it with the refactor function.
So my question is: Does Eclipse have that functionality as QT Creator has?
Related
I've just recently changed from MacOS/Xcode to Windows/VS so I'm a little confused on how to do some things, but I was wondering how I could create a source file with a matching header at the same time instead of doing each file separately. XCode on Mac asks if you also want to create a header with the source file but I cant seem to see that anywhere on VS.
Am using Win11 and the latest version of VS.
I have done it by pressing Ctrl+Shift+X when C++ project is selected in solution explorer of Visual Studio. It should open a class wizard where you can add new or modify existing C++ classes.
Properties:Add New Item->C++ Class
Click OK.
Or
Create a .h file from function in cpp file:
Click the function name to highlight it.
ALT+SHIFT+F10-> Create Declaration/Definition
Maybe there are other plugins can do it.
I'm looking for a way to make Visual Studio Code recognize object names from QtCreator's form (.ui) file. I really don't like to use QtCreator as a code editor, and I want to use it only for designing windows, which requires the .ui file. The problem is that QtCreator parses the object names from the .ui XML file to give code suggestions, even when the objects are not defined in an actual .hpp or .cpp file. VSCode does not do this, and shows a lot of errors in the code and does not suggest object/function/method names. I don't seem to find a way to get this functionality in VSCode. Is there a plugin or something similar that can do this?
The only way to deal with this problem is to turn the .ui file into a .cpp file, and point to it in an include statement at the top of your main code.
To do the conversion, use the 'UIC'.
https://doc.qt.io/qt-5/uic.html
The only problem is that you'll have to do this conversion every time you make a change to the .ui file.
I found the answer after a bit of researching. There is a VS Code extension called Qt Tools that parses object names from the .ui file and shows code suggestions for those objects for seamless Qt development.
I got into a discussion with somebody that tells me that it's not good to do what Qt does with include files because i adopted the same strategy in my code.
Let's use QApplication as an example, when you want to include QApplication then you should do:
#include <QApplication>
QApplication is a file without extension that contains:
#include "qapplication.h"
The only disadvantage is see is that it creates more files in the project. Besides that i think it only has advantages.
So my question is, why is this a good or a bad idea?
I think it is the matter of personal taste, mostly. Different projects use different style. Qt picked up this style.
1) It is basically partially matching the standard library includes without the header extension, although CamelCase. It is different in that regard though that the standard library does not allow these days to use the suffixed version.
2) It could also help with class includes within a header with a different main class. See this example:
#include <QFoo>
where QFoo is defined in qbar.h since the main class is QBar, but there is another class put into the same header.
The only disadvantage is see is that it creates more files in the project.
It does not create more files than needed because these could be generated on the fly like in the Qt Project. In that case, it does not clutter your source tree, and will be put into the build directory, or at least a separate place where it does not get in your way. This is done currently by syncqt in the Qt Project.
Using header files with no extension is not a good idea as it makes it difficult to search header files (*.h or *.hpp) and it makes it more difficult to identify the contents of a file (for example if your editor relies on the extension to choose the proper syntax highlighting mode). Also it causes to have more files in the project as you mentioned.
Also Qt uses that convention exactly because smart programmers don't. It means your headers won't clash with new Qt headers.
So i think using your header files with extensions separates your custom header files from Qt ones in some way. It makes it more clear and clean that which header is for Qt and which one is yours.
I have a C++ project which uses Makefile,now i want to use QT creator for development but I do not want to touch the Makefile, Is there any way QT creator with an existing Makefile.
When you make a new QT Creator project, you are able to edit the make file in the program.
I haven't not had any trouble with adding in my own files, libraries ect. into it, from another, non-QT project.
If you want to avoid the make file all together there is an import function in the GUI to bring in outside files, but I would keep an eye on what it is doing. I have had it make 'creative' choices on what to do with files.
Edit To Include Answer: You can change the exact steps that are used to make the project in the project tab on the left side.
I was wondering if anyone know of a quick and easy way to refactor the code files in my QT Project using QTCreator? Specifically I am trying to organize my source files and Its a bit of a pain to have to go back into the project file and change the filepath for each file. Not to mention moving a dialog class is even worse (there are .ui files not included in the project but you have to change those too.
The only file renaming/moving support that is "integrated" (i.e. it updates your project file automatically) is using the active project pane with your file list, rightclick and select "rename", using "../../some/new/dir/name.cpp" to move your files. It will of course not update any #include statements, but will save you the trouble of modifying your .pro file manually. It also respects "git rename" etc...
I don't think thats possible, moving files without ide support is a pain in the... :/