如何自定义Qt,以便在每个新的cppf文件中添加某些功能? [英] How to customise Qt, so it add certain functions in every new cppf file?

查看:72
本文介绍了如何自定义Qt,以便在每个新的cppf文件中添加某些功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Qt 的新手,我想知道是否可以在我们添加新的 C++ 源文件时自动添加 .h 文件中的某些函数声明和 .cpp 文件中的定义.例如,如果我添加新的 cpp 源文件(cpp + h 文件),Qt 应该自动添加添加函数 initialiseApp(),它在 h 文件中的声明和在 cpp 文件中的定义.如果我创建新项目,这也应该有效.这使我的工作变得轻松,因为我必须在所有 cpp 文件中添加某些功能.谢谢:)

I am a newbie to Qt, and I was wondering if it was possible to automatically add certain functions declaration in .h file and definition in .cpp file, whenever we add new c++ source file. For ex, if I add new cpp source file(cpp + h file), Qt should add automatically add function initialiseApp(), its declaration in h file and its definition in cpp file. This should also work if I create new project. This makes my work easy as I have to add certain functions in all cpp files. Thanks :)

抱歉我造成的混乱.我的意思是 Qt Creator(编辑器)我只希望编辑器在我添加新的 C++ 源文件时添加自定义函数.例如,每当我添加新的 C++ 源文件时,它都应该在头文件(其声明)和 cpp 文件(仅其定义)中添加一个名为 initialiseObjects() 的函数.我知道 refractor 选项存在,但我懒得在每个新的 cpp 头文件中键入声明并右键单击它以添加定义.再次为造成的混乱感到抱歉

Sorry for the confusion I created. I meant Qt Creator(The Editor) I just want the editor to add custom functions whenever I add new C++ source file. For Ex, whenever i add new c++ source file it should add a function called initialiseObjects() in header file(its declaration) and in cpp file(just its definition). I know that refractor option exists but i am just too lazy to type the declaration in every new cpp header file and right click on to it to add definition. Once again Sorry for the confusion created

推荐答案

只需转到您的文件夹:

{Path to Qt installation}\Tools\QtCreator\share\qtcreator\templates

在这里您可以找到所有默认模板并在那里修改它们.

In here you can find all default templates and modify them there.

这篇关于如何自定义Qt,以便在每个新的cppf文件中添加某些功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆