问题包括vscode manjaro linux中的QT文件

发布于 2025-02-09 14:49:13 字数 1189 浏览 1 评论 0原文

我已经与C ++合作了几年,我决定尝试简单的GUI开发。我知道C ++通常不被视为一种进行GUI开发的很好的语言,但是我对此非常满意,并且在制作简单的GUIS制造C ++时已经成功地使用了C ++。我已经看到人们在Visual Studio代码上运行QT代码,目前我正在尝试为自己设置。我在互联网上四处寻找一些指南或至少一些指导,但是我发现的几乎没有过时或为其他操作系统设计(我使用Manjaro Linux)。任何帮助将不胜感激!

c_cpp_properties.json文件:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/qt6/**",
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

game.h(从启动项目中自动生成的QT代码)

#ifndef GAME_H
#define GAME_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui { class Game; }
QT_END_NAMESPACE

class Game : public QMainWindow
{
    Q_OBJECT

public:
    Game(QWidget *parent = nullptr);
    ~Game();

private:
    Ui::Game *ui;
};
#endif // GAME_H

我遇到的错误:无法打开game.h行上的第4行上的“ qmainwindow”

我尝试通过将/usr/include/qt6添加到我的配置文件中来解决问题,但这无济于事。我确定这是一个相当简单的问题,因此,请感谢您的耐心配合!

I have been working with c++ for a few years now and I have decided to try my hands at simple GUI development. I know that c++ is not generally regarded as a great language to do GUI development, but I am very comfortable with it and have had success using c++ with QT Creator at making simple GUIs. I have seen people running QT code on Visual Studio Code and I am currently trying to set it up for myself. I looked around on the internet for some guides or at least some instruction, but what little I found was either outdated or designed for a different os (I use Manjaro Linux). Any help would be greatly appreciated!

c_cpp_properties.json file:

{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**",
                "/usr/include/qt6/**",
            ],
            "defines": [],
            "compilerPath": "/usr/bin/g++",
            "cStandard": "c17",
            "cppStandard": "c++14",
            "intelliSenseMode": "linux-gcc-x64"
        }
    ],
    "version": 4
}

game.h (Auto-generated QT code from starting a project)

#ifndef GAME_H
#define GAME_H

#include <QMainWindow>

QT_BEGIN_NAMESPACE
namespace Ui { class Game; }
QT_END_NAMESPACE

class Game : public QMainWindow
{
    Q_OBJECT

public:
    Game(QWidget *parent = nullptr);
    ~Game();

private:
    Ui::Game *ui;
};
#endif // GAME_H

The error I am getting: cannot open source file "QMainWindow" on line 4 of game.h.

I tried to address the problem by adding /usr/include/qt6 to my configurations file, but that didn't help anything. I am sure this is a fairly simple include issue, so thank you for your patience!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文