I could not find a way to inform macdeployqt that I need QT_ROOT/qml/QtWebView/libdeclarative_webview.dylib to be copied into the app bundle. This is needed to use native QtWebView in QML (configured with QT_WEBVIEW_PLUGIN=native). Is there a way to avoid manual copying and rely on macdeployqt instead?
Note that the library QT_ROOT/plugins/webview/libqtwebview_darwin.dylib is correctly recognized and included in the bundle.
The project is built with cmake, Qt version is 5.15.2. Essential steps are shown below.
find_package(Qt5 REQUIRED COMPONENTS ... WebView)
target_link_libraries(${binary} ... Qt5::WebView)
execute_process(
COMMAND ${qt_root}/bin/macdeployqt
${CMAKE_INSTALL_PREFIX}/bin/my_app_bundle.app
-qmldir=${qt_root}/qml
)
The issue was in misusing qmldir and qmlimport. Correct invocation is
execute_process(
COMMAND ${qt_root}/bin/macdeployqt
${CMAKE_INSTALL_PREFIX}/bin/my_app_bundle.app
-qmldir=${CMAKE_CURRENT_SOURCE_DIR}/quick_ui
-qmlimport=${qt_root}/qml
)
Related
I have a Qt Quick project that uses CMake as its build system. I mostly went with the Qt Creator-generated CMake project, so I have
set(CMAKE_AUTORCC ON)
in my root CMakeLists.txt.
I recently learned about ahead-of-time compiling for QML resources which is supposed to yield quite a bit of startup time improvement. The documentation that describes how to use this with CMake says that I need to do the following:
find_package(Qt5 COMPONENTS Quick Core Network)
find_package(Qt5QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES})
qt5_use_modules(myapp Quick Core Network)
but as far as I see, qtquick_compiler_add_resources does nothing but produce a list of C++ files which don't exist. I assume those would be produced by the QtQuick compiler, but as it is, CMake doesn't run because it can't find those sources. What is the missing bit?
Sorry, a bit late to the party but have to you tried removing the set(CMAKE_AUTORCC ON) ?
I have almost the same implementation and the <qmlfile_name>_qml.cpp files are generated and compiled correctly.
In my implementation I have :
a different CMake property name (resource_files)
I am not using AUTORCC
I'm auto-generating the qrc/qmldir files in the build directory (but that shouldn't matter)
I added the qml files list in the add_executable parameter list because I want to see them in my IDE.
Can please someone explain in detail how to build a single qt module. I tried to understand the build sources documentation, but there is no info on how to build just a single module, let alone what to do with it after. I would like to do some modification on the qtmultimedia module, build it with the changes and use that module in my existing QT installation. I need only the IOS part.
Use the qmake executable from the Qt build you want to build with to create a Makefile. Then run make.
<path_to_qt_build>/bin/qmake <path_to_module>
make [or nmake or jom for windows]
After configuring process just put:
make -j<N> module-<foo>,
where "foo" is a module's name you are desired of
I've been trying to import an open-source project into Qt-Creator to read the code and to learn from it by debuging. Unfortunatly I cannot build imported projects. I found two interessting projects:
https://sourceforge.net/projects/qpass/files/source/
and
https://github.com/keepassx/keepassx
I imported them into Qt Creator by File-->New File or Project-->Import Project-->Import as qmake Project (Limited Functionality). Afterwards I tried to run the project and I got an error:
G:\Qt Projekte\keepassx-2.0.3\src\autotype\test\AutoTypeTest.h:23: Fehler: autotype/AutoTypePlatformPlugin.h: No such file or directory
The file is definitely existing and it's within the project. I googled it and found that there might be problem when importing Qt4 projects into Qt5. Some user recommended to insert 'Qt += widgets' into the pro-File. But it didn't solve my problem.
Does anybody have an idea how to fix it? Is the way how I am importing projects into Qt Creator wrong?
Instead of "New File or Project", you want to use "Open File or Project". Since both projects use cmake, you should be opening their topmost CMakeLists.txt file. I've verified that both of the projects open that way on OS X with Qt/Creator from macports and build successfully using either the default CodeBlocks - Unix Makefiles CMake Generator, or CodeBlocks - Ninja.
Here are the things I had to do to get the builds going:
Add the macports binary path (/opt/local/bin) to the system environment in the project's build settings. That's so that cmake would find ninja. This is optional if you don't use ninja, but ninja speeds up builds by a good integer factors so it's recommended over make.
Add the /opt/local/include path to the INCLUDE_DIR path in QPass's CMakeLists.txt: otherwise it wouldn't find gcrypt's include files from macports. That wouldn't be a problem on most linux distributions, but you'd need a similar fix on windows.
I'm trying to build a Qt Quick Controls application with CMake. I use the following documentation:
http://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html
When running CMake, I'm getting this error:
By not providing "FindQt5QuickCompiler.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"Qt5QuickCompiler", but CMake did not find one.
Could not find a package configuration file provided by "Qt5QuickCompiler"
with any of the following names:
Qt5QuickCompilerConfig.cmake
qt5quickcompiler-config.cmake
at this line:
FIND_PACKAGE(Qt5QuickCompiler)
Obviously CMake doesn't find Qt5QuickCompiler. I checked in my Qt folder (C:\Qt) but it's not there. Yet I could run this application with QMake.
What do I need to set in order to find Qt5QuickCompiler?
I just stumbled upon the same issue with Qt 5.12 under Linux. The documentation under https://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html currently seems to be wrong.
Use QuickCompiler after COMPONENTS in the Qt5 find_package instead of trying to add it via find_package(Qt5QuickCompiler). Adapting the example from the link, use
find_package(Qt5 COMPONENTS Quick Core Network QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)
instead of
find_package(Qt5 COMPONENTS Quick Core Network)
find_package(Qt5QuickCompiler)
qtquick_compiler_add_resources(RESOURCES example.qrc)
add_executable(myapp ${SRC_LIST} ${RESOURCES)
The error is pretty clear: CMake doesn't have a module for the Qt5QuickCompiler to find it. It just doesn't know what it is. I've just checked the corresponding cmake folder and it doesn't have that file. I'm not sure what that Qt documentation page is talking about but there is no such a file in the CMake distribution. Maybe Qt sources have this file somewhere?
You need to build Qt5 with Qt Quick compiler which you can download from http://www.qt.io/qt-quick/. In the build directory of Qt Quick compiler, you will find Qt5QuickCompilerConfig.cmake.
Copy the path to this directory, and add to CMAKE_PREFIX_PATH like this
cmake -DCMAKE_PRFEIX_PATH=<pathToFile> <pathToSrcDirOfYourProject>
Currently I am using the command line compilation for my project and i used cmake to configure my project. so for my project i already have my CMakeLists.txt configured.
Now I'm planning to build project using the QT Creator. The problem is that I do not want to rewrite configuration settings again to use qmake so. Put differently, i am kind of trying to keep cmake as my default configuration tool. So is there any way i can still use my good old CMakeLists.txt file.
Qt Creator should allow you to open a CMake project. I haven't tried this, but see http://doc.qt.nokia.com/qtcreator-2.2/creator-project-cmake.html