2016-06-25 13 views
3

を読み込むことができませんでした私はimport QtQuick.Controls 2.0アプリケーションが次のエラーでロードに失敗したときにそのプロジェクトがそうQt5.7CMake、 を使用して生成されたアプリを持っています.txtのVisual Studioの出力にロードされ輸入QtQuick.Controls QQmlApplicationEngineコンポーネント

set(CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.7.0\\5.7\\msvc2015") 
set(CMAKE_AUTOMOC ON) 
set(CMAKE_AUTORCC ON) 
set(CMAKE_AUTOUIC ON) 
set(CMAKE_INCLUDE_CURRENT_DIR ON) 

find_package(Qt5Core REQUIRED) 
find_package(Qt5Qml) 
find_package(Qt5Quick) 
find_package(Qt5QuickControls2) 

... 

add_executable(MyApp ${SRC} ${HEADER} ${RESOURCES}) 

target_link_libraries(MyApp 
Qt5::WinMain  
Qt5::Core 
Qt5::Qml  
Qt5::Quick 
Qt5::QuickControls2  
) 

DLLファイル:

'MyApp.exe' (Win32): Loaded 'C:\Qt\Qt5.7.0\5.7\msvc2015\qml\QtQuick.2\qtquick2plugind.dll'. Symbols loaded. 
'MyApp.exe' (Win32): Loaded 'C:\Qt\Qt5.7.0\5.7\msvc2015\qml\QtQuick\Controls.2\qtquickcontrols2plugind.dll'. Symbols loaded. 
'MyApp.exe' (Win32): Unloaded 'C:\Qt\Qt5.7.0\5.7\msvc2015\qml\QtQuick\Controls.2\qtquickcontrols2plugind.dll' 
+0

どのファイルが 'C:\ Qt \ Qt5.7.0 \ 5.7 \ msvc2015 \ qml \ QtQuick \ Controls.2'にありますか?それはプラグインのデバッグバージョンを探しているようですが、あなたのQtインストールはそれを利用できますか? – jpnurmi

+0

はい、dllファイルがパスにあり、Visual Studio(インテリセンスのシンボルが読み込まれています)に読み込まれていますが、アプリケーションを読み込めません。 –

+1

何らかの理由でプラグインがすぐにアンロードされますか?私はそれが何を引き起こすのか分かりません。 Dependency Walkerでプラグインを開くとどうなりますか?これはインストーラからあらかじめビルドされたQtインストールですか?もしそうなら、Qtクイックコントロール2ギャラリーのサンプルは機能しますか? – jpnurmi

答えて

4

解決策が見つかりましたQtQuick.Controls 2.0QtQuick.Templates 2.0モジュールに依存していますので、そのディレクトリを出力ディレクトリにコピーして正常に実行されています。 (デバッグバージョン)

必要なDLL:(リリースバージョン用)

Qt5QuickTemplates2d.dll 
Qt5QuickControls2d.dll 

必要なDLL:WindowsのQtの上

Qt5QuickTemplates2.dll 
Qt5QuickControls2.dll 
+0

これはQtのCMakeインテグレーションが自動的に処理するかどうかですか?依存関係のチェーン全体を手作業でリストアップする必要があるのは通常のことですか?それとも、QQC2のどこかに依存関係の宣言がありませんか? – jpnurmi

+0

実際、QtGuiとQtXmlPatternsはどちらも明示的にリストされていないことに気づいたので、依存関係をある程度解決する必要があります。 – jpnurmi

0

は、自動的にすべてのQtとQMLの依存関係をスキャンする展開ツールを提供します。

%QTDIR%\bin\windeployqt.exe your_app.exe --qmldir your\qml\files 

See the Qt documentation:

The tool can be found in QTDIR/bin/windeployqt. It takes an .exe file or a directory that contains an .exe file as an argument, and scans the executable for dependencies. If a directory is passed with the --qmldir argument, windeployqt uses the qmlimportscanner tool to scan QML files inside the directory for QML import dependencies. Identified dependencies are then copied to the executable's directory. The hardcoded local paths in Qt5Core.dll are furthermore replaced with relative ones.