Qt QtQuick 使用Qt靜態庫無法找到qml

2021-07-28 16:27:29 字數 890 閱讀 8513

除錯執行提示

qrc:/main.qml:2

module

"qtquick.controls"

isnot installed

qrc:/main.qml:1

module

"qtquick"

isnot installed

qrc:/main.qml:2

module

"qtquick.controls"

isnot installed

看了幾篇文章解決方案都不優雅,提供乙個自認為比較好的方法,告訴程式去**載入qml

int main(int argc, char *argv)

還有一種是這樣匯入,在qml資料夾中找到模組的描述檔案qmldir ,根據裡面的module classname匯入

q_import_plugin(classname) //使用類名

qobject_cast(qt_static_plugin_module().instance())->registertypes("qtquick"); //使用帶類名的函式和 模組名字串

qobject_cast(qt_static_plugin_qtquick2plugin().instance()) ->initializeengine( &engine, "qtquick");

int main(int argc, char *argv)

qt靜態編譯

qt靜態編譯出現以下問題怎麼解決呢?d qt 5.9.0 qtbase src corelib global qlibraryinfo.cpp fatal error c1853 qmake pch.pch 預編譯標頭檔案來自編譯器的早期版本,或者預編譯頭為 c 而在 c 中使用它 或相反 nmak...

QT中靜態庫的生成與使用

一.靜態庫的生成 1.測試目錄 lib 2.原始碼檔名 mywindow.h,mywindow.cpp,類mywindow繼承於qpushbutton,並將文字設定為 i m in class mywindow 3.編寫專案檔案 mywindow.pro 注意兩點 template lib conf...

QT的靜態編譯

qt預設的編譯方式是動態編譯的,但是有時候你編寫的程式要發布出去,帶很多動態庫檔案是很繁瑣的,此時就需要靜態編譯你的程式,qt要實現靜態編譯必須庫檔案也是靜態編譯的,可以用這個命令編譯靜態庫 配置編譯選項 開啟 qtdir mkspecs win32 g qmake.conf qtdir 為qt庫所...