I can add headers to the header path but how can I bring in external headers to be available within Creator for editing in project, so they appear in the file list like other headers created from scratch? in Xcode, you could just drag files into the project, they'd be copied into the project directory and appear in the IDE for editing. I'd assume you could do this in Creator but I can't find any way to do so.
Right Click on the project -> Add Existing Files... -> Choose your desired external headers
this way you can edit them (but it is not recommended to edit external headers)
Note: This way, the files will get compiled with your project, so you need to include all dependencies.
Use qmake - project from the command line in the directory containing the files and they will generate a .pro and you can copy that into a .pri and then include the .pri in your project, thus allowing you to access and edit the files from within Creator but segregating them nicely should you choose to use those files in other projects as well, but maintaining a single set of build and qmake settings.
If you add project headers to a target in CMakeLists.txt, they'll show up in Qt Creator.
file(GLOB HEADERS src/*.hpp src/*.h)
file(GLOB SOURCES src/*.cpp)
add_library(FreenectDriver SHARED ${HEADERS} ${SOURCES})
Related
How can I tell doxygen to (only) use the files that are in my Qt project file when generating the documentation?
Reason for asking: I'm using a folder structure where a 'common' folder holds files that are used by some (not all) Qt projects I'm working on. Like this:
projects
MyProject
common_files
SubProject_A
SubProject_B
Both SubProject folders will have a Doxyfile and both projects will use some files from the common_files folder.
I know one way to achieve my goal (getting the documentation for just the files used in my project) is to manually add all files in the INPUT setting from the doxygen configuration file. But that would mean I'll have to change the Doxyfile every time I add or delete a file to/from my project.
Doxygen should be able to filter the files needed for the documentation from the .pro file. But how?
I am new to Qt. I installed Qt 5 but when i create a new project (Qt widget application) i do not find headers and source files like main.cpp and mainwindow.ui and mainwindow.cpp Although *.pro file is there but nothing else.
mainwindow.cpp does appear on the text editor but there is a message above that
"This file is not the part of any project."
When i checked inside the project directory i can see all the files present but in Qt creator i can not access any of them.
Please help.
The files that Qt Creator generates for you when you create a new project depend on the type of project that you choose to create. F.ex. when you create a new Empty qmake Project, only the .pro file is being created. You can choose a different type of project when creating one, so that Qt Creator will auto generate some more files depending on your needs.
You can add new files to your project by right clicking on the main project folder in Projects menu and choosing either Add New... to create a new file or Add Existing Files... to point Qt Creator to the files that you already have.
This will add a link to the new file in to the .pro file. Lower is the content of the .pro file after adding a couple of new files to the project.
You can also edit the .pro file by hand instead of using the IDE, but Qt Creator (and qmake as well) won't know about the files in your project folder until you add them to the .pro file.
We would like to associate different kind of styles to different projects. I have been looking for and Qt Creator in its new version (4) has the possibility to autoformat files on saving using Beautifier.
My Question is if there is any way to associate for example a style file to one project to be opened when we open that project.
That file would be in the root folder of the project and would be downloaded automatically from the repository.
Looking at the 'Beautifier' options, I see that 'Artistic Style' and 'Uncrustify' has an option to use a file from the project directory as the style file. It's up to you to create these files for each project.
Update for clangformat: If you select the "File" option from the "Predefined Styles" list, clang-format should use a file from the project directory. For more info see the description for -style argument here.
I'm using qt 5.3 under windows 7. Every time I edit the .pro file I need to clean up Makefile file under output/building folder to make it re-parse the changed pro file. I want it automatically detect the change when I hit build or run.
Is there some config I miss-set?
Three ways to re-parse the .pro file:
Right-click the project name in the Project pane (the topmost item) and select Run qmake
Click the Build/Run qmake menu option
Edit the .pro file, press Ctrl-S, and let Qt Creator automatically reparse it
It sounds like the third option is what you want and it's not working for you. It has traditionally been flakey and I never rely on it -- I use the first technique, right-clicking the Project and choosing Run qmake.
I'm using QWebView to run a web app. There are 650+ files. Placing the web app's directory in the source directory does not result in the executable bundling the directory.
How do I include the entire web app directory so that the executable will be able to render the files.
Note: I have currently added index.html as a resource, and can access it with qrc:// - But since I cannot add the entire directory structure to a qrc (can I?), the executable does not include the other files.
You need to put an XML node into the .qrc file for each file you want to use using the Qt resource system.
This can be done using a simple pre-build script. Take a look at qrcgen. Quoting the blog post behind this link:
The script I created, qrcgen, takes a directory and a prefix, recursively scans the directory and generates a .qrc file with the same name as the directory scanned. It has solved my problem, and I hope it can help others. It is also available via PyPI, just "easy_install qrcgen".
In order to update the .qrc file whenever your directory contens change, you need to include this step into your build process:
For C++/Qt projects, you can add this step in the build configuration in QtCreator or add in your qmake file a system(...) statement. Note that such commands aren't portable in general. (If it's not portable, you can put some operating system conditions around multiple commands.)
For PyQt/PySide projects, I don't know how to do this, but I'm sure you find a solution for this too.