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

arabicsara 2010-08-31 04:42:37
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改了一下),之后就编译出错了
...全文
13755 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
keneth2078 2012-09-22
  • 打赏
  • 举报
回复
顶部的objectName 是不容易轻易改变的。得出结论了。
int8 2012-09-07
  • 打赏
  • 举报
回复
也就是说,不能轻易改变顶层部件的objectname?
小小橙123 2012-07-30
  • 打赏
  • 举报
回复
多谢12,13楼,我也碰到同样问题。
love666love 2012-03-28
  • 打赏
  • 举报
回复
我是修改了QObject的objectname出现的错误,解决办法同12楼。
bluesnow208 2012-02-12
  • 打赏
  • 举报
回复
把.ui文件里的objectName修改成其他头文件里引用的名称。
这是你修改ui类带来的错误。
linux_leaner 2011-12-01
  • 打赏
  • 举报
回复
我也碰到了这个问题,不过我把mainwindow.cpp中包含头文件ui_mainwindow.h的语句转移到mainwindow.h中就行了,因为mainwindow.h中有使用到Ui::MainWindow
shixinjing 2011-06-16
  • 打赏
  • 举报
回复
谢谢chenlee的详细解释!
ChenLee_1 2011-05-03
  • 打赏
  • 举报
回复 7
我也碰到了同样的问题,后来发现,用qtDesigner设计的UI主界面,是这样命名的:class Ui_mainWindow
而在ui_mainwindow.h文件的最后,有这么一句话,namespace Ui {
class mainWindow: public Ui_mainWindow {};
} // namespace Ui ,也就是说,Ui_mainwindow被放在了Ui命名空间;
而在QT Creator的mainwindow.h里面,前向申明是这样写的:namespace Ui {
class MainWindow;
}
细心的朋友估计已经发现了,这里应该是class mainWindow,而QT默认的却写成了class MainWindow;换句话说,这是qt的一个bug.
arabicsara 2010-12-17
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 mrdone 的回复:]

熊猫,你没有说明是怎么解决的!
[/Quote]不好意思哈,我是这么解决:每次改完mainwindow的名字id就会出现这种错误,比如mainwindow设置成mainwindow2,而qt代码里没有自动都转成mainwindow2
mrdone 2010-12-17
  • 打赏
  • 举报
回复
熊猫,你没有说明是怎么解决的!
  • 打赏
  • 举报
回复
应该是类没有实体,找不到构造函数。
lefttime 2010-09-01
  • 打赏
  • 举报
回复
光看头文件没什么问题, 只是在类中声明, 将实现引用于源文件而已;
把源文件也贴出来看看, 这样也许更容易定位问题所在```~
arabicsara 2010-09-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 lingcheshenyou 的回复:]
头文件中因为Ui::MainWindow类只用了一个指针,所以之前的
namespace Ui{
class MainWindow}
就已经足够了
但是这个提示信息说的是你在MainWindow的构造函数中使用了一个没有实体的类,也就是说你忘记了在mainwindow.cpp中包含 ui_mainwindow.h。如果使用了一个类的实体(与指针相对)但是编译器找不到这个类的实现,那么就会报……
[/Quote].cpp里有ui_mainwindow.h了
千羽鸣 2010-09-01
  • 打赏
  • 举报
回复
头文件中因为Ui::MainWindow类只用了一个指针,所以之前的
namespace Ui{
class MainWindow}
就已经足够了
但是这个提示信息说的是你在MainWindow的构造函数中使用了一个没有实体的类,也就是说你忘记了在mainwindow.cpp中包含 ui_mainwindow.h。如果使用了一个类的实体(与指针相对)但是编译器找不到这个类的实现,那么就会报这个错误。
一定是这样的,对不对?
arabicsara 2010-08-31
  • 打赏
  • 举报
回复
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <qprogressbar.h>
#include <QTreeWidgetItem>
#include "dialog_filter.h"
#include "ui_mainwindow.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
explicit MainWindow(QWidget *parent = 0);
~MainWindow();
public:
int FindFile(const QString & path);
int SearchIntofile(const QString &file_name,const QString &str_find,QTreeWidgetItem* parent=0);
private:
Ui::MainWindow *ui;
Dialog_filter dlg_filter;
// QProgressBar *progressbar;
bool b_SearchFileContnt;//查找文件内容
bool b_CaseSensitive;//大小写敏感
private slots:
void on_pushButton_jump_clicked();
void on_pushButton_filter_clicked();
void on_toolButton_browser_clicked();
int search();
int about();
int AddFav();
void CaseSensitive();
};

#endif // MAINWINDOW_H
原来没有#include "ui_mainwindow.h",加上去也是一样的错误啊
巴依老爷 2010-08-31
  • 打赏
  • 举报
回复
看上去你大概是忘了#include "ui_mainwindow.h"
源码下载地址: https://pan.quark.cn/s/0d6e3002ba51 ### IR2110中文资料知识点详述 #### 一、概述 IR2110是一种专为脉冲宽度调制应用而设计的高性能驱动集成电路,在各类功率转换设备中具有广泛的应用,特别是在需要实现隔离驱动的场景下表现出色。该芯片融合了光电隔离与电磁隔离的优势,能够达成快速响应并保持较小的物理尺寸,尤其适合用于中小功率的变换装置。 #### 二、IR2110内部结构与特点 **1. 内部结构** - **封装形式**:采用DIP14引脚封装。 - **内部组成**:由逻辑输入单元、电平平移单元以及输出保护单元这三个主要部分构成。 - **悬浮电源**:借助自举电路实现,使得高端工作电压最高能够达到500V,支持±50V/ns的电压变化率。 - **工作电压范围**:逻辑电源电压范围为5~15V,输出电源端电压范围为10~20V,易于与其他逻辑电平进行匹配。 - **工作频率**:最高可达到500kHz。 - **功耗**:在15V条件下静态功耗仅为116mW。 - **延迟时间**:导通延迟120ns,关断延迟94ns。 - **峰值输出电流**:图腾柱输出峰值电流为2A。 **2. 特点** - **独立输入通道**:具备独立的低端和高端输入通道配置。 - **兼容性**:逻辑电源地与功率地之间允许±5V的偏移量,便于与TTL或CMOS电平进行匹配。 - **自举电源**:内置自举电源电路,有效减少驱动电源的数量,从而简化电路设计。 - **高dv/dt能力**:具有较强的dv/dt抑制能力,适合高频开关应用。 - **低功耗**:工作状态下功耗较低,有利于提升整体效率。 #### 三、高压侧...

21,498

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧