门户
书籍
教程
论坛
问答
下载
签到
个人空间
帐号
自动登录
找回密码
密码
登录
立即注册
账号
自动登录
找回密码
密码
登录
立即注册
请绘制轨迹完成人机验证
由vaptcha提供技术支持
登录
注册
搜索
搜索
搜索
热搜
qml
quick
串口
输入中文
数据库
arm
百度地图
qt聊天
QT安装
安装
多窗口
中文乱码
聊天
局域网
鼠标
QT
图片
乱码
rs485通讯
多线程
android
多文档编辑器
本版
用户
本版
用户
【HUX】问题互助平台
博客
动态
好友
帖子
收藏
道具
勋章
任务
淘帖
动态
日志
相册
分享
记录
留言板
群组
门户
导读
排行榜
设置
我的收藏
退出
Qt开源社区
›
精华区(请在“有问必答”发帖)
›
有问必答
›
QML和QtQuick
›
Chart和QtGraphicalEffects静态编译的问题
发布主题
返回列表
Chart和QtGraphicalEffects静态编译的问题
6
回复
8165
查看
[复制链接]
adadadda
当前离线
积分
106
adadadda
累计签到:3 天
连续签到:1 天
来源:
2017-1-13 08:03:39
显示全部楼层
|
阅读模式
1
Qter豆
一直想静态编译代码,但是在代码中使用了Chart和QtGraphicalEffects模块。Chart模块在别的电脑运行,QtGraphicalEffects无法编译。
因为我想使用Control 2,所以我用的Qt 5.8,顺便吐槽一句Qt 5.7的Control 2的BUG实在有点多,并且莫名其妙。
工程文件代码如下:
QT += qml quick
QT += core gui widgets
QT += charts
CONFIG += c++11
SOURCES += main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS
# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
复制代码
chart需要用到Widget里面的东西,所以必须添加Widget,并且在main.c的代码里面要app类型为
QApplication
main.c文件代码如下:
#include <QQmlApplicationEngine>
#include <QtWidgets/QApplication>
#include <QtPlugin>
Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QLatin1String("qrc:/main.qml")));
return app.exec();
}
复制代码
main.qml中的代码
import QtQuick 2.7
import QtQuick.Controls 2.1
import QtQuick.Layouts 1.0
import QtCharts 2.1
import QtGraphicalEffects 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
SwipeView {
id: swipeView
anchors.fill: parent
currentIndex: tabBar.currentIndex
Page {
Button{
anchors.centerIn: parent
text:"First page"
layer.enabled: hovered
layer.smooth: true
layer.effect: DropShadow {
color: activeFocus ? "#330066ff" : "#aaaaaa"
verticalOffset: 3
horizontalOffset: 3
radius: 6
samples: 12
spread: 0.7
}
}
}
Page {
ChartView {
title: "Line"
anchors.fill: parent
antialiasing: true
LineSeries {
name: "LineSeries"
XYPoint { x: 0; y: 0 }
XYPoint { x: 1.1; y: 2.1 }
XYPoint { x: 1.9; y: 3.3 }
XYPoint { x: 2.1; y: 2.1 }
XYPoint { x: 2.9; y: 4.9 }
XYPoint { x: 3.4; y: 3.0 }
XYPoint { x: 4.1; y: 3.3 }
}
}
}
}
footer: TabBar {
id: tabBar
currentIndex: swipeView.currentIndex
TabButton {
text: qsTr("First")
}
TabButton {
text: qsTr("Second")
}
}
}
复制代码
静态编译所用的命令符:
configure.bat -confirm-license -opensource -platform win32-g++ -mp -debug-and-release -static -prefix "D:\Qt\5.8.0_MinGW_static" -qt-zlib -qt-libpng -qt-libjpeg -opengl desktop -qt-freetype -no-qml-debug -no-angle -nomake tests -nomake examples -skip qtwebengine -skip qtwebview
这个命令符是什么意思,我只能看懂-skip qtwebengine -skip qtwebview?会不会是静态编译包在制作的时候没有把Chart和QtGraphicalEffects编译进去?
还有一个问题,在Qt 5.8默认的编译器下,DEBUG会出现如下的问题,Release版本则不会:
ASSERT failure in void QtFontFamily::ensurePopulated(): "SimSun", file text\qfontdatabase.cpp, line 425
Invalid parameter passed to C runtime function.
Invalid parameter passed to C runtime function.
我在网上找了相关的信息,有人遇到了,但是解决办法我没有看懂。链接如下:
http://blog.csdn.net/zyzhaojun/article/details/52491041
我来回答
相关帖子
QT工程上的静态代码分析有哪些好用的工具呢?
如何在工程中使用ChartView?在线等,急急急!!!!!
qt5MulTimediaWidgets.dll 没有指定在windows上运行,求解?
关于工程文件,如何添加一个宏定义,如所有的子工程有效
调用C++类
Qt 怎样设置字体大小不受电脑的字体设置而改变大小
回复
使用道具
举报
adadadda
当前离线
积分
106
adadadda
累计签到:3 天
连续签到:1 天
2017-1-14 07:36:42
显示全部楼层
没人么?????????????????????????
回复
使用道具
举报
adadadda
当前离线
积分
106
adadadda
累计签到:3 天
连续签到:1 天
2017-1-16 07:37:05
显示全部楼层
有没有人啊,求告知啊
回复
使用道具
举报
adadadda
当前离线
积分
106
adadadda
累计签到:3 天
连续签到:1 天
2017-1-18 18:47:56
显示全部楼层
没人么????????????????????????????????????????????
回复
使用道具
举报
adadadda
当前离线
积分
106
adadadda
累计签到:3 天
连续签到:1 天
2017-2-4 16:07:58
显示全部楼层
没有人帮助一下么。。。。。。。。。。。。。。。。。。。。。。。。。。。
回复
使用道具
举报
adadadda
当前离线
积分
106
adadadda
累计签到:3 天
连续签到:1 天
2017-2-24 09:40:48
显示全部楼层
求帮助啊,真的不知道怎么办了
回复
使用道具
举报
adadadda
当前离线
积分
106
adadadda
累计签到:3 天
连续签到:1 天
2017-2-24 09:45:42
显示全部楼层
问了好几个论坛都没有人回复,哎,用Qt的人这么少吗?好郁闷。。。话说是不是我的头像有问题
回复
使用道具
举报
返回列表
发表新帖
高级模式
B
Color
Image
Link
Quote
Code
Smilies
您需要登录后才可以回帖
登录
|
立即注册
公告
可以关注我们的微信公众号yafeilinux_friends获取最新动态,或者加入QQ会员群进行交流:190741849、186601429(已满)
我知道了