QT+qtcharts+qtdatavis3d
环境说明
Ubuntu 20.04 + Qt 5.6.3 + qtcharts 5.7.0 + qtdatavis3d 5.7.0
一、 QT
1. 源替换
cd /etc/apt/
sudo cp -i /etc/apt/sources.list /etc/apt/sources.list_backup
sudo apt-get install vim
sudo vim sources.list
立即键入 gg 将光标移动到文件的第一行 直接输入dG 回车删除全部文本行
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
2. 更新
sudo apt-get update
sudo apt-get upgrade
3. QT所需环境配置
sudo apt-get install clang
sudo apt-get install build-essential
sudo apt-get install aptitude
sudo aptitude install libqt4-dev
chmod +x qt-opensource-linux-x64-5.6.3.run
./qt-opensource-linux-x64-5.6.3.run
在选择组件的时候,勾选全选就可。 下一步直到安装完成。
二、QtCharts
1. 关于qmake
qmake -v
Command ‘qmake’ not found
解决: QTDIR中添加自己qt安装路径,注意路径下要有lib和bin文件夹。
sudo vim ~/.bashrc
export QTDIR=/home/lee/BuildTools/Qt5.6.3/5.6.3/gcc_64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
export PATH=$PATH:$QTDIR/bin
source ~/.bashrc~/.bashrc
2. qtCharts
这里使用getee的仓库地址,下载比较快。
sudo apt install git
git clone https://gitee.com/scottgreen/qtcharts.git
cd qtcharts
git checkout 5.7
qmake
make
sudo make install
3. make报错
报错1:
GL/gl.h: No such file or directory
sudo apt-get install mesa-common-dev
报错2: cannot find -lGL
sudo ln -s /home/lee/BuildTools/Qt5.6.3/Tools/QtCreator/lib/qtcreator /usr/lib/libGL.so
报错3: Failed to load module "canberra-gtk-module
sudo apt-get install libcanberra-gtk-module
4. 复制qtcharts
cd /home/lee/qtcharts/qtcharts/examples
cp -r charts/ ~/Qt5.6.3/Examples/Qt-5.6.3
5. 生成qtcharts帮助文档
cd /home/lee/qtcharts/qtcharts/
make docs
6. 复制qtcharts帮助文档
cd qtcharts/qtcharts/doc
cp -r * ~/Qt5.6.3/Docs/Qt-5.6.3
三、qtdatavis3d
1. qtdatavis3d
tar -zxvf qtdatavis3d-opensource-src-5.7.0.tar.gz
cd qtdatavis3d
qmake
make
sudo make install
2. 复制qtdatavis3d
cd /home/lee/qtdatavis3d/examples
cp -r * ~/Qt5.6.3/Examples/Qt-5.6.3/
3. 生成qtdatavis3d帮助文档
cd /home/lee/ToolComponents/qtdatavis3d-opensource-src-5.7.0
make docs
4.复制qtdatavis3d帮助文档
cd /home/lee/qtdatavis3d/doc
cp -r * ~/Qt5.6.3/Docs/Qt-5.6.3/
四、验证
创建一个Qt项目,main.cpp中包含qtcharts和qtdatavis3d头文件,不报错说明安装成功。
五、资源下载
https://download.csdn.net/download/kevenbalabala/85082996
参考
https://blog.csdn.net/m0_37806112/article/details/82623486 http://c.biancheng.net/view/3901.html https://blog.csdn.net/weixin_33805992/article/details/85932975 https://php.wekeepcoding.com/article/10792742/Cross-compiling+QtDeclarative+for+raspberry+pi
|