QT: error: invalid use of incomplete type ‘class Ui::Widget‘ , ui(new Ui::Widget) 错误处理办法 -1

实际遇到:

QT: error: invalid use of incomplete type 'class Ui::Widget' , ui(new Ui::Widget) 错误处理办法

参考:

Qt5.7中编译报错:“invalid use of incomplete type 'class Ui::xxx'ui(new Ui::xxx)”的解决方法  https://blog.csdn.net/Green_Hand_in_IT/article/details/80516599

invalid use of incomplete type class ui(new Ui::MainWindow)报错,解决方案  https://blog.csdn.net/qq_53873381/article/details/129971073

** [Error] invalid use of incomplete type 使用了未定义的类型  https://blog.csdn.net/weixin_62264287/article/details/125246807 
因为这两个类是相互勾结了,所以其中一个类在使用另一个类进行对象实例化的时候,另一个类也会去找这个类对象实例化,而它们都还没有定义,简单来说就是,我需要你帮我做一件事A,但是你为了做事A需要我做事B,而我做事B必须建立在你帮我做事A的前提下。

关联参考:

QT: error: invalid use of incomplete type ‘class Ui::Widget‘ , ui(new Ui::Widget) 错误处理办法 -2
https://blog.csdn.net/ken2232/article/details/129771629

QT: error: invalid use of incomplete type ‘class Ui::Widget‘ , ui(new Ui::Widget) 错误处理办法 -1
https://blog.csdn.net/ken2232/article/details/135581921

==========================================

 

QT: error: invalid use of incomplete type 'class Ui::Widget' , ui(new Ui::Widget) 错误处理办法  << 实际遇到

  https://www.cnblogs.com/asuser/articles/13019936.html

错误 1:

在QT中更改QWidget的对象名称后,

对应的源代码中类的名称变为:

转到对应的widget.cpp添加部分代码后报错如下:

将对象名称修改为提示的Widget后重新再编译,错误消除。

错误 2:没有包含 #include <QWidget>  时,如下:也会出现同样错误提示。

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

//....

}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值