1、no match for 'operator=='
error: no match for 'operator==' (operand types are 'ConfigINI_CPP' and 'const ConfigINI_CPP')
if (n->t() == t)
该错误提示可能是因为你在不需要的地方调用了比较操作符(比如 QList 内部需要进行查找、删除或者排序操作时)。如果你不需要比较 ConfigINI_CPP 对象的内容,考虑是否有必要进行这类操作,或者使用其他方法来处理。
重载 operator== 时避免误用:
2、std::bad_alloc
std::bad_alloc
是 C++ 标准库中的异常,通常表示 动态内存分配失败 。当 new
或 std::malloc
无法分配所需的内存时,就会抛出 std::bad_alloc
。
可能是 数组过大 ,或者有大量的动态分配,但没有及时释放。
3、Cannot queue arguments of type
QObject::connect: Cannot queue arguments of type 'QList<DiscernResult*>'
(Make sure 'QList<DiscernResult*>' is registered using qRegisterMetaType().)
个错误是由于 Qt 的信号和槽机制在默认情况下无法处理某些类型的参数(如 QList<DiscernResult*>)进行队列连接时所导致的。具体来说,当信号在不同线程之间传递时,Qt 会自动将参数放入事件队列(即使用 Qt::QueuedConnection),但是默认情况下 QList<DiscernResult*> 类型没有被注册为元类型,因此 Qt 无法正确处理它。
解决方法:
// 注册 QList<DiscernResult*> 类型
qRegisterMetaType<QList<DiscernResult*>>("QList<DiscernResult*>");
4、error: invalid use of incomplete type
error: invalid use of incomplete type 'struct PulseExtraChara_CPP'
return data()[i]; }
~~~~~~^
你遇到的错误 invalid use of incomplete type 'struct PulseExtraChara_CPP' 通常是由于尝试访问未完全定义的类型或结构体导致的。在 C++ 中,如果你在使用某个类型时该类型的声明不完整(即只有前向声明而没有完整定义),编译器就会无法推断该类型的具体内容,从而报出这个错误。
解决方法:
头部文件引入,或前向声明
5、error: cannot open output file debug\xxx.exe: Permission denied
:-1: error: cannot open output file debug\xxx.exe: Permission denied
6、QThread: Destroyed while thread is still running
7、QSplitter最大化问题
最大化问题,使用分割器QSplitter,添加组件deviceControl、collectControl 和 controlSpectrum,当我最大化controlSpectrum,需要执行两次才能最大化。
因为 QSplitter 会强制分配空间给其子控件(deviceControl、collectControl 和 controlSpectrum),即使你尝试最大化窗口,QSplitter 仍然会保持其布局比例。
目前的解决方案是不使用QSplitter,使用普通的水平垂直布局。没找到使用QSplitter布局的解决方案。
8、QMainWindow状态栏不见问题
状态栏不见:大小策略
ui->stackedWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Ignored); // 垂直策略改成Ignored忽略大小调整解决切换界面超过屏幕导致状态栏不见问题
9、terminate called after throwing an instance of 'std::bad_alloc'
// size 读取错误,导致超大 std::vector 分配 terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
std::vector<double> vec(size);
size太大,多半是size读取异常导致过大