• 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时会报错;

  • 相关阅读:
    Javascript中Promise对象的实现
    SQL 问题记录
    转:十步完全理解SQL
    转:SQL Server 动态行转列
    SQL in、not in、exists和not exists的区别:
    SQL之left join、right join、inner join的区别
    转 .NET4.5之初识async与await
    macOS USB连接iPhone反复重连解决方法
    MacOS: 找到被占用的端口并释放
    解决rust编译包含diesel类库时,cannot find -lmysqlclient的错误
  • 原文地址:https://www.cnblogs.com/FKdelphi/p/13211703.html
Copyright © 2020-2023  润新知