在QT创作者中没有标题或源文件。

huangapple go评论48阅读模式
英文:

No headers or source files in QT creator

问题

我在创建QT中的新头文件和源文件时遇到了问题。我只能将新文件添加到构建中,如下所示,对于“主”项目而言,它是灰色的。

在QT创作者中没有标题或源文件。

我可以为构建专门创建它们,它们只会出现在文档区域中,没有头文件树分支。在我关闭qt后,我必须创建新的文件。我希望它们出现在树中并与主项目连接在一起。我已关闭“隐藏源文件和头文件”选项。

在QT创作者中没有标题或源文件。

我显然尝试按照yt上显示的方式创建它们。我已经搜索了设置,但没有找到任何可用的选项。

英文:

I'm having a problem with creating new header and source files in QT. I can only add new files to the build, it's grayed for the "main" project as you can see below.

在QT创作者中没有标题或源文件。

I can create them specifically for the build and they only appear once in the documents area. There is no header tree branch. After I close qt I have to create new ones. I want them to appear in the tree and be connected with the main project. I have "hide source and headers files" option off.

在QT创作者中没有标题或源文件。

I've obviously tried creating them the way it was shown on the yt. I've searched through settings but didn't found anything I could use.

答案1

得分: 1

你需要在CMake中手动添加这些文件。

  1. 转到文件>新建文件,然后选择你需要的文件类型。通常会是源文件、头文件,或者两者都有(类文件)。

  2. 编辑CMakeLists.txt文件:

      qt_add_executable(myapp
            myapp.qrc
            main.cpp
            new_file.cpp
            new_file.h
      )

类似*.qml文件和像图片(.png .jpg)之类的资源都要添加到myapp.qrc文件中。

英文:

You will have to add the files manually in CMake.

  1. Go to File>New File and select what type of file you want. Typically it will be a source, header, or both (class).

  2. Edit the CMakeLists.txt file:

      qt_add_executable(myapp
            myapp.qrc
            main.cpp
            new_file.cpp
            new_file.h

    )

Resources like .qml files and things like images (*.png *.jpg) are added in the myapp.qrc file

huangapple
  • 本文由 发表于 2023年2月6日 20:59:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75361632.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定