Header- and Sourcecode Files integration in a main Programm
-
Hello everyone,
I'm new to Qt Creator and I have a 'small' problem.
On (OpenSuse) Linux, I'm using Creator 9.0.2 and I want to subdivide my main program (via #include)
and integrate one or more separate *.hpp file(s).
When I create a new project (Qt console application), a main.cpp file is always created under the correct project name.
Questions:- How do I create an hpp file? (new project?)
- How do I create the associated cpp file? (new project?)
- Where do I have to save the hpp and cpp files so that the project/main program can integrate them?
- Is it possible to integrate these additional source files when creating the project?
-
Hi and welcome to devnet,
There's no need to create new projects for these files. From your description it seems you want to create new classes so go that route and your project should be automatically updated.
-
You know that Qt is just a C++ framework. There's nothing special here. If you want to have Qt Creator help you create new files, there's a menu for that under File.
Qt Creator -> File -> New File -> Select C++ Class, fill the information and you will have a pair of C++ header/implementation files created and added to your project.
Otherwise, you can create these files manually as you would any other and then manually update your project file.
Qt Creator has a pretty extensive documentation worth reading.Two things to take into account:
- Qt 6 has moved to CMake for project management. While qmake is still supported, it's not recommended to start new projects with it.
- Qt Creator 9 is pretty old, you should maybe consider getting a more recent version which also has better cmake support.
-
-
Don't hesitate to open new topics if other issues arise.