QT编程问题记录

来源:互联网 发布:pb9.0精彩编程100例 编辑:程序博客网 时间:2024/04/28 00:31

1. error: jump to label ‘xxx’

在QT中编译有goto语句的代码时出现类似错误,在eclipse中却没错。

/home/anzyelay/workspace/QT/myarmtest/camera.cpp:327: error: jump to label '__error2'/home/anzyelay/workspace/QT/myarmtest/camera.cpp:221: error:   from here/home/anzyelay/workspace/QT/myarmtest/camera.cpp:269: error:   crosses initialization of 'long unsigned int* picdata'/home/anzyelay/workspace/QT/myarmtest/camera.cpp:230: error:   crosses initialization of 'long unsigned int* fbp32'/home/anzyelay/workspace/QT/myarmtest/camera.cpp:228: error:   crosses initialization of 'long int screen_size'

原因是GCC 和G++的内部变量处理不一样,
认真看错误提示可以知道,从此处跳转到__error2时crosses了后面几个变量的初始化所以出错,将后面的变量定义放到goto之前就可以解决这个问题

2.下断点调试CAMERA时出现无法下断点的问题.

在调试摄像头时,在相关的摄像头函数里无法下断,甚至在其整个CPP里(camera.cpp)的任何函数都无法下断点进入,但在界面函数main,mainwindow等处却可以正常下断。
这里写图片描述
写了个helloworld测试函数,排除是函数错误引发的无法下断问题。
使用QDEBUG调试发现程序是进入start里面了,但是没有摄像头就跳出来了,
这里写图片描述
后来发现是插上摄像头就能正常进入里面的断点了。

3.error: undefined reference to `class::xxx’

在编译类的定义实现中出现如下错误
这里写图片描述
我定义的类如下:

class camera{public:    camera();    ~camera(){        if(fd>=0)            close(fd);    };private:    int fd;};

把camera()实现下就行,如下所示:

public:    camera(){};    ~camera(){        if(fd>=0)            close(fd);    };

4. Debugging Qt app with Qt Creator: no such value

参考文章
在Ubuntu 12.04中使用QT Creator 3.6.1调试程序时查看任何变量都是显示 no such value,调试模式那些都是好的。
参考说明文档Qt Creator Manual

Starting with version 3.1, Qt Creator requires the Python scripting extension. GDB builds without Python scripting are not supported anymore and will not work. The minimal supported version is GDB 7.5 using Python version 2.7, or 3.3, or newer.

查看自己电脑的gdb 版本,12.04自带的是7.4的,我自己编译安装的是7.11,看了下设置发现QT creator 用的是7.4的版本,
这里写图片描述

anzyelay@ubuntu:gdb-7.11$ /usr/bin/gdb -vGNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04anzyelay@ubuntu:gdb-7.11$ /usr/local/bin/gdb -vGNU gdb (GDB) 7.11

在kit中更换成7.11的,运行结果如下
这里写图片描述
很明显,我上回编译时没有–with-python,重新编译7.11带上Python

anzyelay@ubuntu:gdb-7.11$ ./configure --with-pythonanzyelay@ubuntu:gdb-7.11$ makeanzyelay@ubuntu:gdb-7.11$ sudo make install

上述默认安装在/usr/local/bin中
在KIT中选中这版GDB,这回调试就ok了。

5.在编译qt quick application时,在PC上built时没问题,但交叉编译时却出现:Project error: Unknown module(s) in QT: quick

遇到的问题与这个相同,就是built qt quick的应用例程时也是一样,PC机的可以,cross compile就不行了。
还有一篇文章
出错原因:
根据网友的说法,查看了下自己交叉编译出来的qt里的lib库插件,确实没有libQt5Quick.so,而pc安装的QT里却有,因此编译此文件移植到文件系统中。在tools->option->built and run的qt versions中你可以看到最下面详情那里交叉编译的qmake 没有QML Dump这个程序,PC桌面版是有的,在概要信息报错里提示:

QML module does not contain information about components contained in plugins.Module path: /home/anzyelay/Qt5.6.0/5.6/gcc_64/qml/Qt/labs/controls/materialSee "Using QML Modules with Plugins" in the documentation.Automatic type dump of QML module failed.Errors:"/home/anzyelay/Qt5.6.0/5.6/gcc_64/bin/qmlplugindump" returned exit code 3.Arguments: -nonrelocatable Qt.labs.controls.material 1.0 /home/anzyelay/Qt5.6.0/5.6/gcc_64/qmlQQmlComponent: Component is not ready

报的就是这个错。如果把交叉编译的KIT里的qt versions换成桌面版 的试了下可以build出来,就是执行出错。看来确实是交叉编译的QT里缺少了库,检查了下主要是qtquickcontrols,qtquickcontrols2这两项模块没有编译出来。进入里面单独编译时出错,

anzyelay@ubuntu:build.4.4.3$ cd qtquickcontrolsanzyelay@ubuntu:qtquickcontrols$ lsMakefileanzyelay@ubuntu:qtquickcontrols$ lsMakefileanzyelay@ubuntu:qtquickcontrols$ makeSome of the required modules (qtHaveModule(quick)) are not available.Skipped.
0 0