Qt Creator Code File Refactoring - c++

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... :/

Related

How do I make VS Code parse Qt object names from .ui file?

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.

Visual C++: automatic include refactoring when moving/renaming files

I just moved from CodeBlocks to Visual Studio 2013, and this is my first time using VS2013. My CodeBlocks project used virtual folders for structure, while keeping all the "physical" files in the same directory (I know, I know...) So I just spent an incredibly tedious 45 minutes replicating that structure with actual folders, creating folders and moving files around. The worst part was that, for each and every header file, I had to run a search-and-replace command like the following to update its path: #include "ObjectPtrArray.h" => #include "Structures/ObjectPtrArray.h"
This is a fairly large project (120+ source files), and I'm going to be doing much, much more refactoring over the coming days. A lot of that will include renaming classes, splitting them, creating new folders, moving files from folder to folder, and such. So is there any way I can automate this process? i.e. if I have a header file Tiles/SceneMap.h and I move it to Graphics/Tiles/SceneMap.h, can Visual Studio (or an extension for it) automatically update all of the includes that reference this file, without me having to run search-and-replace manually?
I do have ReSharper, but when I right click on a file the Refactor menu is blank. Is there another extension that I can use which would do this (preferably not conflicting with ReSharper?)
Thanks for your time!

How do i use a bunch of .h and .cpp files to create a static library that can be used in another c++ Project

I am trying to learn C++ from some Stanford Course and they have a custom library which contains a bunch of header files(.h) and their associated source (.cpp) files.
I want to create new C++ projects in xcode 6.x to try out code and include those custom header files in my new projects.
I have no freaking idea how to include those files in my project so that i can peacefully #include "blahblahblah.h" and use functions from that header file without issues.
I am new to both xcode, c++(although i know some coding part) and anything else with this process.
Summary:
I have a folder Library which contains a series of .h and .cpp
files.
I have XCode 6.x.x/Eclipse installed.
I want to create a new C++ project and use #include
"OneOfThoseHeaderFiles.h" and then use a function or something from
those header files.
Also assume i have no clue how to run some command line codes that i see a lot of.
If someone can please tell me in the most simple way(preferably step-by-step) i would be so eternally grateful and sing praises to you until the day i die :)
Note: Either XCode or Eclipse is fine. I really just want to start coding.
I have spent the better part of a whole week trying out xcode, eclipse etc and trying to follow a ton of steps to get it working but i just cant get how to add the files without issues. Either the info seems to be for Xcode 4.x and every menu seems changed or the suggestions are so complicated that a novice like me cant figure it out.
First off, almost all the information for Xcode will be available on the Apple Developer's portal:
https://developer.apple.com/library/prerelease/ios/documentation/ToolsLanguages/Conceptual/Xcode_Overview/start_project.html#//apple_ref/doc/uid/TP40010215-CH2-SW5
To create a simple static library on Xcode 6 you start by creating a new project, then under OS X - Framework and Library select Library, on the next window change the Framework to None (Plain C/C++ Library) and static (since that is what your are stating).
Once your project is created, add the existing headers and sources to your project, either by dragging them with the mouse or with the add files drop menu from the right click functionality, you can create a new group in Xcode if you want some order for them.
When adding the files, on the add window shown you can select to either copy them or use their current location.
If needed you might have to change the "header search path" in your target configuration under "Build Settings", if it is the first time you are using Xcode some of this will sound weird but I am sure you will find most of it on the Apple Developers portal in great detail.
If you want to test the files without having to create an external static library you could create a command line project and test them faster and easier.

Is it possible to export a project directly from visual Studio into it's own folder?

I am currently trying to build .net bindings for a very large project that is written in C an C++. The project was recently ported over to Windows, and I might add that is is a big giant mess.
The solution has about 12 projects, which is fine but the directory itself has alot more files than needed,since it includes OS specific source files, demo projects etc.
Also the other thing is the headers and source files are scattered all over the place. I am working on a parser to help me create the bindings for this project, but I am having a heck of a time. Especially when the internal include references are completely off.
The developer did a great job porting this large project to Windows, but isn't very organized and it is driving me bonkers with the issue my parser is having. So the easiest thing to do would be to re structure and put each project in it's own areas.
So as I asked in the title, is there somewhere that I can export each project and it's files from VS 2010(or another tool) so I can begin restructuring the folders? When I have ever needed to do this before in .net it was easy enough to just move the files. In smaller c++ projects I just open up the project file in notepad++ and move each file in the include/source list into different directories and changed the paths in the project file after. The issue with that is it will take way too long, and I have already spent days messing with this project, finding the best way to wrap it, and creating my helper tools.
Can anyone give me some assistance in this aspect?
EDIT:Just to clarify, I would like to export each project into it's own root folder with one folder for headers and one for source files so I can keep things simple.
I'm not sure about a tool for this, but the .vcxproj project files are in XML format, so you can easily extract a list of files from each project. Then you could relocate those files and write their new location back into the project.
Whenever I encounter a serious project mess, I usually end up dragging all the project files into Notepad++ and start doing global search and replace.
I haven't done it on the scale that you seem to be aiming at, where it involves relocating all the sources. You could be in for a rough ride. Fixing up include paths etc could be quite a pain.
I suggest you obtain the file lists (relative paths or whatever) in a simple text format, and then decide whether you want to take the red pill or the blue pill =)

Redeveloping MFC application

I've got a program written in c++ and have to make some modifications to it. Howerver, I haven't got any solution file or a like, just a bunch of .h, .cpp, .obj, .dpb, .dll, .mdi, .dfm, .res, .tds, .bpl files and an .exe file.
So I can start an application, see what it's doing and what the controls are, but when it comes to adding changes trying do to map behaviour of UI to source code files seems just to tedious.
Is it possible to recreate some kind of solution file or just to simply the process? (I am using VS 2012 and an app was written in 2002).
These file extensions indicate the source is from a Borland IDE. That .mdi file I think signifies Borland's multiple-document-interface... I'll venture to guess this project would be quite difficult to "recompile" using Visual Studio. I don't even see a .rc (resource file) in your list. Rewriting may be the easiest path, depending on the complexity of the application...