主要工作是将lib文件进行抽离,从而避免对QtDesignerComponents 和 QtDesigner 的DLL依赖,而且可以任性的修改为我所用.
效果:
学到了如何将系统已有的文件"整块移植"
已知
问题:
release在QtCreator直接
编译运行程序会崩溃(可以通过windeployqt引入相应dll文件后再次运行就OK了), debug版本无此问题
代码来源:
安装
目录下src文件下的工程
要点:
0.将原工程中的除designer.pro和其上级
pro之外的pro都屏蔽掉,同时将屏蔽后的pro中的pri文件添加到designer.pro中,注意
文件顺序(参考原pro文件),在添加时可以通过在工程上右键"添加到工程"将文件加到pro文件中后,修改为include("相对路径"),从而可以解决相对路径问题
1.增加
DEFINES +=
QT_DESIGNER_STATIC,用来避免dll导出警告(和一部分
错误)
2.对于出现的mutidefine问题,可以屏蔽相应的cpp文件达到目的(pri文件中)
3.在编译遇到undefine refrence之类的问题时,仔细辨别如果缺失没问题,这时删除所有新生成的文件重新编译也许是个不错的主意
4.在release模式崩溃时,使用windeployqt 将所需dll拷贝过去即可
5.屏蔽掉工程中的
Q_INIT_RESOURCE(widgetbox);之类的东西(只有
插件才需要初始化资源)
6.如果要修改和系统重名的(DLL中的东西)可通过修改包含文件, 如
将#include <QtDesigner/QDesignerComponents> 替换为#include "../lib/components/qdesigner_components.h"7. 在工程中加上如下代码可以排除对designer模块的依赖INCLUDEPATH += ../../../../include/QtDesigner/5.7.0../../../../include/QtDesigner/5.7.0/QtDesigner../../../../include/QtDesigner
8.在编译设置的自定义步骤的方式可以添加批处理文件来达到自动化的目的 window.open('http://www.qtcn.org/bbs/attachment/Mon_1903/44_151927_3a089b2de00280f.png?482');" style="max-width:700px;max-height:700px;" onload="if(is_ie6&&this.offsetWidth>700)this.width=700;" >9.在编译设置中修改编译参数-j8(本次有效)或者在系统环境变量中增加(一劳永逸)来大大的加快编译进程
拷贝.bat文件- echo off
- set PATH=C:\Qt\Qt5.7.0\5.7\mingw53_32\bin;C:/Qt/Qt5.7.0/Tools/mingw530_32\bin;%PATH%
- IF EXIST ..\build-designer-Desktop_Qt_5_7_0_MinGW_32bit-release\src\designer\bin\designer.exe. IF NOT EXIST ..\build-designer-Desktop_Qt_5_7_0_MinGW_32bit-release\src\designer\bin\Qt5Core.dll. windeployqt ..\build-designer-Desktop_Qt_5_7_0_MinGW_32bit-release\src\designer\bin\designer.exe
designer.pro文件
- QT += core-private widgets xml network gui-private
- QT += widgets-private
- #QT += designer-private designercomponents-private
- qtHaveModule(printsupport): QT += printsupport
- INCLUDEPATH +=
- ../lib/sdk
- ../lib/components
- ../lib/extension
- ../lib/shared
- ../components
- extra
- INCLUDEPATH +=
- ../../../../include/QtDesigner/5.7.0
- ../../../../include/QtDesigner/5.7.0/QtDesigner
- ../../../../include/QtDesigner
- RESOURCES += designer.qrc
- contains(QT_CONFIG, static) {
- DEFINES += QT_DESIGNER_STATIC
- }
- DEFINES += QT_DESIGNER_STATIC
- include(../lib/extension/extension.pri)
- include(../lib/shared/shared.pri)
- include(../lib/sdk/sdk.pri)
- include(../lib/uilib/uilib.pri)
- include(../../../shared/fontpanel/fontpanel.pri)
- include(../../../shared/qttoolbardialog/qttoolbardialog.pri)
- include(../components/propertyeditor/propertyeditor.pri)
- include(../components/objectinspector/objectinspector.pri)
- include(../components/signalsloteditor/signalsloteditor.pri)
- include(../components/formeditor/formeditor.pri)
- include(../components/widgetbox/widgetbox.pri)
- #include(../components/buddyeditor/buddyeditor.pri)
- include(../components/taskmenu/taskmenu.pri)
- #include(../components/tabordereditor/tabordereditor.pri)
- SOURCES += ../components/lib/qdesigner_components.cpp
- HEADERS +=
- qdesigner.h
- qdesigner_toolwindow.h
- qdesigner_formwindow.h
- qdesigner_workbench.h
- qdesigner_settings.h
- qdesigner_actions.h
- qdesigner_appearanceoptions.h
- saveformastemplate.h
- newform.h
- versiondialog.h
- designer_enums.h
- appfontdialog.h
- preferencesdialog.h
- assistantclient.h
- mainwindow.h
- SOURCES += main.cpp
- qdesigner.cpp
- qdesigner_toolwindow.cpp
- qdesigner_formwindow.cpp
- qdesigner_workbench.cpp
- qdesigner_settings.cpp
- qdesigner_actions.cpp
- qdesigner_appearanceoptions.cpp
- saveformastemplate.cpp
- newform.cpp
- versiondialog.cpp
- appfontdialog.cpp
- preferencesdialog.cpp
- assistantclient.cpp
- mainwindow.cpp
- #PRECOMPILED_HEADER=qdesigner_pch.h
- FORMS += saveformastemplate.ui
- preferencesdialog.ui
- qdesigner_appearanceoptions.ui
- win32 {
- RC_FILE = designer.rc
- }
- DESTDIR = bin
工程代码
win7可直接编译版本 calcProject_base_ok.zip (6576 K) 下载次数:28