I have a project in QT Creator and I want that the header files be included automatically when using a new object. It's like in Eclipse : Add needed headers when invoking a new object by using Ctrl+Alt+Space : all needed headers will be included.
Here is an example
#include <QApplication>
#include <QPushButton> /* Header that i want to include automatically */
int main( int argc, char *argv[ ] )
{
QApplication app( argc, argv) ;
QWidget fenetre;
/*Add needed headers when invoking a new object like ctrl+alt+space in eclipse*/
QPushButton bouton( "Bonjour", &fenetre) ;
bouton. move(70,60);
fenetre. show( ) ;
return app. exec( ) ;
}
Any suggestions on how to do this in QT Creator ? Thanks
In QT Creator version 4.1.0 you have option for that under right click (move your cursor over type you want to include, click, choose refactor and there it is)
shortcut for that is (Alt+Return) to trigger quick fix , you can see what is the shortcut for it if it does not work on your machine Tools -> Options -> Environment -> Keyboard (Search for quickfix).
Not exactly as you requested, but: if you would like to create a new class with the help of Qt Creator you can certainly have Qt Creator taking care of immediate include files as well:
Qt Documentation: Creating Projects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With