文章目录
- 1.环境:
- 2.问题及解决方案
- 2.001 QAxBase: Error calling IDispatch member Item: Exception thrown by server
- 2.002 ASSERT failure in QList<T>::at: "index out of range"
- 2.003 default argument given for parameter 1 of 'void Widget::dynamically_creating_CheckBox(QVector<int>*, STATE_TYPE_T)' void Widget::dynamically_creating_CheckBox(QVector<int> *data = new QVector<int>,STATE_TYPE_T input = INIT_STATE ) ^
- 2.004 QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object
- 2.005 out memory of
- 2.006 QT做串口通信时,出现错误
- 2.007 error: unterminated conditional directive
- 2.008 -1: error: No rule to make target '../zifeng/picture/???.jpg', needed by 'debug/qrc_res.o'. Stop.
- 2.010 widget.cpp:-1: In member function 'virtual void Widget::dragMoveEvent(QDragMoveEvent*)':
- 2.011 qt程序异常结束。
- 3.参考文献:
1.环境:
qt 5.8,win10
2.问题及解决方案
2.001 QAxBase: Error calling IDispatch member Item: Exception thrown by server
解决方法
参数传输有误,
worksheetnum 是一个随机值,未初始化
2.002 ASSERT failure in QList::at: “index out of range”
解决方法
遍历QList 范围有问题,找到对应定义QList
2.003 default argument given for parameter 1 of ‘void Widget::dynamically_creating_CheckBox(QVector*, STATE_TYPE_T)’ void Widget::dynamically_creating_CheckBox(QVector *data = new QVector,STATE_TYPE_T input = INIT_STATE ) ^
解决方法
函数声明和实现都是缺省参数格式,修改函数实现为正常参数就行
/*缺省参数不能在函数定义和声明中同时出现*/
void Widget::dynamically_creating_CheckBox(QVector<int> *data ,STATE_TYPE_T input )
2.004 QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object
解决方法
原:
[A-Za-z0-9_-\u4e00-\u9fa5]+
修改:
[A-Za-z0-9_\-\u4e00-\u9fa5]+
C++中""是转义字符
参考链接Getting error “called on an invalid QRegularExpression object”
2.005 out memory of
解决方法
.pro 文件 添加 CONFIG+=resources_big
2.006 QT做串口通信时,出现错误
error: undefined reference to `_imp___ZN15QSerialPortInfo14availablePortsEv’
error: undefined reference to `_imp___ZN11QSerialPortC1EP7QObject’
等错误时,
解决方法
只需要在.pro中添加
QT+=serialport
就可以了。
参考链接
2.007 error: unterminated conditional directive
#ifndef MENU_H
#define MENU_H
解决方法
宏定义有问题,没有#endif 或者重新编写一下
2.008 -1: error: No rule to make target ‘…/zifeng/picture/???.jpg’, needed by ‘debug/qrc_res.o’. Stop.
解决方法
删除原资源文件,重新添加
2.009. qt光标 变成黑块
解决方法
按了小键盘中的Insert键
2.010 widget.cpp👎 In member function ‘virtual void Widget::dragMoveEvent(QDragMoveEvent*)’:
connect(this,&Widget::makeAPatch(),this,&Widget::makeAPatchSlot());
//修改为
connect(this,&Widget::makeAPatch,this,&Widget::makeAPatchSlot);
2.011 qt程序异常结束。
解决方法
网上查资料
参考资料
Qt Creator中编译运行Qt项目时报“程序异常结束”错误的解决思路
1.未声明,未定义就使用
2.ui界面相关未定义使用
3.dll 库缺失
4.越界,空指针,野指针等
实际问题
定位发现
qDebug()<< "scan "<< scan ;// 0
qDebug()<< "ready "<< ( newsize / 50) ;// 0
qDebug()<< "ready emit complete"<< scan / ( newsize / 50) ;// 越界
稍微细细研究一下
c环境下,菜鸟编程
printf("Hello, World! %d \n",0/0);
/*
main.c: In function ‘main’:
main.c:6:35: warning: division by zero [-Wdiv-by-zero]
6 | printf("Hello, World! %d \n",0/0);
| ^
run: line 1: 3 Floating point exception(core dumped) ./a.out
Exited with error status 136
*/
感兴趣可以看看大佬写的
【进阶】除数为0,程序会奔溃吗?