首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > QT开发 >

invalid use of incomplete type 'struct Ui:MainWindow如何解决

2012-02-10 
invalid use of incomplete type struct Ui::MainWindow怎么解决?XML codemainwindow.cpp: In constructo

invalid use of incomplete type 'struct Ui::MainWindow怎么解决?

XML code
mainwindow.cpp: In constructor 'MainWindow::MainWindow(QWidget*)': mainwindow.cpp:12: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:14: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:17: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:18: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:19: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp: In destructor 'virtual MainWindow::~MainWindow()': mainwindow.cpp:33: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:34: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:35: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:39: warning: possible problem detected in invocation of delete operator: mainwindow.cpp:39: warning: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: warning: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:39: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined. mainwindow.cpp: In member function 'void MainWindow::on_toolButton_browser_clicked()': mainwindow.cpp:45: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:53: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:54: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp: In member function 'int MainWindow::SearchIntofile(const QString&, const QString&, QTreeWidgetItem*)': mainwindow.cpp:75: warning: unused variable 'i' mainwindow.cpp: In member function 'int MainWindow::FindFile(const QString&)': mainwindow.cpp:111: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:119: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp: In member function 'int MainWindow::search()': mainwindow.cpp:138: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:146: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp: In member function 'int MainWindow::AddFav()': mainwindow.cpp:179: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' mainwindow.cpp:180: error: invalid use of incomplete type 'struct Ui::MainWindow' mainwindow.h:10: error: forward declaration of 'struct Ui::MainWindow' 

我修改了代码,修改了资源文件(把一个菜单的ObjectName改了一下),之后就编译出错了

[解决办法]
看上去你大概是忘了#include "ui_mainwindow.h"
------解决方案--------------------


头文件中因为Ui::MainWindow类只用了一个指针,所以之前的
namespace Ui{
class MainWindow}
就已经足够了
但是这个提示信息说的是你在MainWindow的构造函数中使用了一个没有实体的类,也就是说你忘记了在mainwindow.cpp中包含 ui_mainwindow.h。如果使用了一个类的实体(与指针相对)但是编译器找不到这个类的实现,那么就会报这个错误。
一定是这样的,对不对?
[解决办法]
光看头文件没什么问题, 只是在类中声明, 将实现引用于源文件而已;
把源文件也贴出来看看, 这样也许更容易定位问题所在```~

热点排行