Qt 调试错误现象及解决方式记录 |
您所在的位置:网站首页 › 调试错误怎么解决方法视频 › Qt 调试错误现象及解决方式记录 |
1、继承了QSerialPort类调试出错。 (1)现象: 对‘QSerialPort::QSerialPort(QObject*)’未定义的引用 对‘QSerialPort::metaObject() const’未定义的引用 对‘QSerialPort::qt_metacast(char const*)’未定义的引用 对‘QSerialPort::qt_metacall(QMetaObject::Call, int, void**)’未定义的引用 对‘QSerialPort::isSequential() const’未定义的引用 对‘QSerialPort::open(QFlags)’未定义的引用 对‘QSerialPort::close()’未定义的引用 对‘QSerialPort::atEnd() const’未定义的引用 对‘QSerialPort::bytesAvailable() const’未定义的引用 对‘QSerialPort::bytesToWrite() const’未定义的引用 对‘QSerialPort::canReadLine() const’未定义的引用 对‘QSerialPort::waitForReadyRead(int)’未定义的引用 对‘QSerialPort::waitForBytesWritten(int)’未定义的引用 对‘QSerialPort::readData(char*, long long)’未定义的引用 对‘QSerialPort::readLineData(char*, long long)’未定义的引用 对‘QSerialPort::writeData(char const*, long long)’未定义的引用 ... (2)原因:使用Qt Serial 模块需要在项目文件添加该模块。 (3)解决方式:To link against the module, add this line to your qmake .pro file(详见链接): QT += serialport2、编译的时候出现对‘vtable for xxx’未定义的引用错误。 (1)现象: undefined reference to `vtable for mySerialWidget' (2)原因: 当在类的头文件中添加Q_OBJECT以后QtCreator会自动的创建一个moc_***.cpp文件,用于实现信号与槽通信的代码。但是,有时当我们通过QtCreator创建类的时候,没有通过IDE选项选择其派生自QObject类,而是在后面添加的,则会出现QtCreator没有自动创建moc_***.cpp文件的情况。(参考链接) (3)解决方式: remove该类的头文件,然后add Existing Files重新将该头文件添加进来,这样QtCreator就会自动为该类创建moc_***.cpp文件。
3、添加view.engine()->rootContext()->setContextProperty("serialPortCtrl", &serialPortCtrl);上下文属性编译出错. (1)现象: error: invalid use of incomplete type ‘class QQmlContext’ (2)原因:没有添加头文件。 (3)解决方式: 添加 #include
4,添加自定义的qml模块,提示无法找到。 (1)现象:提示找不到自定义的模块 (2)原因:模块的文件名首字母要大写,比如myButton.qml作为自定义模块导入是没有作用的,应该写成MyButton.qml。
5,无法解析的外部符号。 (1)现象:提示“main.obj:-1: error: LNK2019: 无法解析的外部符号 "public: __cdecl DataSource::DataSource(class QQuickView *,cl...” (2)解决方法:删除项目文件夹下面的build-xxxx-Desktop_Qt_x_xx_x_xxxxxx_xxbit-Debug文件夹,然后重新编译。
6,定义枚举定义READY、ERROR等出错。 (1)解决方法:改为M_READY、M_ERROR。
7,构建时出现“未找到文件cc1plus.exe,out of memory allocating”。(详见链接) (1)原因:qrc资源文件会直接被存放到静态数组中,从而一直占用内存,使内存的利用率不高。有的时候如果资源过大,可能编译都无法通过,会造成out of memory的错误。 (2)解决方法: 在工程PRO文件中,添加: CONFIG += resources_big8,使用windeployqt生成打包文件后,打开程序出现错误,错误码(0xc000007b)。 (1)原因:windeployqt的位数与qt库位数不一致(32位与64位搞混了)。 (2)解决方法:使用位数一致的windeployqt生成。其他详见这里。
|
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |