• 4862阅读
  • 8回复

[讨论]Chart和QtGraphicalEffects静态编译的问题 [复制链接]

上一主题 下一主题
离线adadadda
 

只看楼主 倒序阅读 楼主  发表于: 2017-01-13
  一直想静态编译代码,但是在代码中使用了Chart和QtGraphicalEffects模块。Chart模块无法在别的电脑运行,QtGraphicalEffects无法编译。

因为我想使用Control 2,所以我用的Qt 5.8,顺便吐槽一句Qt 5.7的Control 2的BUG实在有点多,并且莫名其妙。

工程文件代码如下:
  1. QT += qml quick
  2. QT += core gui widgets
  3. QT += charts
  4. CONFIG += c++11
  5. SOURCES += main.cpp
  6. RESOURCES += qml.qrc
  7. # Additional import path used to resolve QML modules in Qt Creator's code model
  8. QML_IMPORT_PATH =
  9. # Additional import path used to resolve QML modules just for Qt Quick Designer
  10. QML_DESIGNER_IMPORT_PATH =
  11. # The following define makes your compiler emit warnings if you use
  12. # any feature of Qt which as been marked deprecated (the exact warnings
  13. # depend on your compiler). Please consult the documentation of the
  14. # deprecated API in order to know how to port your code away from it.
  15. DEFINES += QT_DEPRECATED_WARNINGS
  16. # You can also make your code fail to compile if you use deprecated APIs.
  17. # In order to do so, uncomment the following line.
  18. # You can also select to disable deprecated APIs only up to a certain version of Qt.
  19. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
  20. # Default rules for deployment.
  21. qnx: target.path = /tmp/${TARGET}/bin
  22. else: unix:!android: target.path = /opt/${TARGET}/bin
  23. !isEmpty(target.path): INSTALLS += target

chart需要用到Widget里面的东西,所以必须添加Widget,并且在main.c的代码里面要app类型为QApplication
main.c文件代码如下:
  1. #include <QQmlApplicationEngine>
  2. #include <QtWidgets/QApplication>
  3. #include <QtPlugin>
  4. Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)
  5. int main(int argc, char *argv[])
  6. {
  7.     QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
  8.     QApplication app(argc, argv);
  9.     QQmlApplicationEngine engine;
  10.     engine.load(QUrl(QLatin1String("qrc:/main.qml")));
  11.     return app.exec();
  12. }

main.qml中的代码
  1. import QtQuick 2.7
  2. import QtQuick.Controls 2.1
  3. import QtQuick.Layouts 1.0
  4. import QtCharts 2.1
  5. import QtGraphicalEffects 1.0
  6. ApplicationWindow {
  7.     visible: true
  8.     width: 640
  9.     height: 480
  10.     title: qsTr("Hello World")
  11.     SwipeView {
  12.         id: swipeView
  13.         anchors.fill: parent
  14.         currentIndex: tabBar.currentIndex
  15.         Page {
  16.             Button{
  17.                 anchors.centerIn: parent
  18.                 text:"First page"
  19.                 layer.enabled: hovered
  20.                 layer.smooth: true
  21.                 layer.effect: DropShadow {
  22.                     color: activeFocus ? "#330066ff" : "#aaaaaa"
  23.                     verticalOffset: 3
  24.                     horizontalOffset: 3
  25.                     radius: 6
  26.                     samples: 12
  27.                     spread: 0.7
  28.                 }
  29.             }
  30.         }
  31.         Page {
  32.             ChartView {
  33.                 title: "Line"
  34.                 anchors.fill: parent
  35.                 antialiasing: true
  36.                 LineSeries {
  37.                     name: "LineSeries"
  38.                     XYPoint { x: 0; y: 0 }
  39.                     XYPoint { x: 1.1; y: 2.1 }
  40.                     XYPoint { x: 1.9; y: 3.3 }
  41.                     XYPoint { x: 2.1; y: 2.1 }
  42.                     XYPoint { x: 2.9; y: 4.9 }
  43.                     XYPoint { x: 3.4; y: 3.0 }
  44.                     XYPoint { x: 4.1; y: 3.3 }
  45.                 }
  46.             }
  47.         }
  48.     }
  49.     footer: TabBar {
  50.         id: tabBar
  51.         currentIndex: swipeView.currentIndex
  52.         TabButton {
  53.             text: qsTr("First")
  54.         }
  55.         TabButton {
  56.             text: qsTr("Second")
  57.         }
  58.     }
  59. }

静态编译所用的命令符:
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

离线adadadda

只看该作者 1楼 发表于: 2017-01-14
没人么?大神呢?
离线adadadda

只看该作者 2楼 发表于: 2017-01-18
最后一个问题为我解决了,删除在注册表中删除红色的部分即可
离线adadadda

只看该作者 3楼 发表于: 2017-01-19
求大神指导
离线adadadda

只看该作者 4楼 发表于: 2017-01-28
不要沉啊,求大神帮助
离线adadadda

只看该作者 5楼 发表于: 2017-02-19
求指导
离线adadadda

只看该作者 6楼 发表于: 2017-02-24
求指导a
离线adadadda

只看该作者 7楼 发表于: 2017-02-27
不要沉啊,求帮助啊。苦恼了我很久了,完全不知道怎么办才好。各位大神,求帮助。。。。。
离线adadadda

只看该作者 8楼 发表于: 2017-02-27
              
快速回复
限100 字节
 
上一个 下一个