zoukankan      html  css  js  c++  java
  • QT-找开工程后,最上方提示the code model could not parse an included file, which might lead to incorrect code completion and highlighting, for example.

    相关资料:

    https://blog.csdn.net/u014453443/article/details/91975453

    问题情况:

    the code model could not parse an included file,which might lead to incorrect code completion and highlighting,for example


    解决办法:

    帮助-->关于插件-->C++-->ClangCodeModel的勾去掉即可

    注意,去掉之后一定要重启Qt Creator

    问题原因:

    CreateMenu.h中定义如下:

     1 #ifndef CREATEMENU_H
     2 #define CREATEMENU_H
     3  
     4 #include <QMenuBar>
     5 #include "mainwindow.h"
     6  
     7 class MainWindow;
     8 class Menu : public QMenuBar
     9 {
    10     Q_OBJECT
    11 public:
    12     Menu(QWidget *parent,MainWindow *p);
    13     ~Menu();
    14 }
    15  
    16 #endif

    mainwindow.h中定义如下:

     1 #ifndef MAINWINDOW_H
     2 #define MAINWINDOW_H
     3  
     4 #include <QMainWindow>
     5 #include "CreateMenu.h"
     6  
     7 namespace Ui{
     8 class MainWindow;
     9 }
    10  
    11 class Menu;
    12  
    13 class MainWindow : public QMainWindow
    14 {
    15     Q_OBJECT
    16 public:
    17     explicit MainWindow(QWidget *parent = nullptr);
    18     ~MainWindow();
    19 private:
    20     Menu i_MenuBar;
    21 }
    22  
    23 #endif

    报这个错误的原因是因为重复包含头文件的原因,CreateMenu.h中包含了mainwindow.h头文件,但mainwindow.h头文件又包含了CreateMenu.h,所以才会导致这种报错的发生,按照上面的解决方案可以完美解决!

    一定要注意在CreateMenu.h中使用MainWindow类时,在头文件开始一定要写上class MainWindow,这是对MainWindow类的声明,否则在使用MainWindow时会报错;同样在mainwindow.h头文件中使用Menu类时,在头文件开始一定要写上class Menu,这是对Menu类的声明,否则在使用Menu时会报错;

  • 相关阅读:
    江西师范大学瑶湖校区图片
    什么是sp?
    教育技术学硕士点学校排名
    西南师大教育技术学专业2005年入学考试信息
    什么是"工包"?
    买书网址
    2006年全国教育技术学专业新增硕士点
    今天终于拿到书了
    2007年教育学专业基础综合考试大纲(重要部分) ——下载地址
    电脑DIY推荐
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/13211703.html
Copyright © 2011-2022 走看看