On Fri, Jan 14, 2022 at 6:16 AM Ulf Hermann <ulf.herm...@qt.io> wrote:
> Is the place where the module's qmldir ends up reachable via the QML > import path? I don't know. I have the generated qmldir in the C:\Programming\tsc\build\debug\TscUi directory, which I think should be correct. I haven't messed with the output paths at all. The application goes to a neighboring directory in C:\Programming\tsc\build\debug\TscApp I can see that the .rcc contains a couple of cpp files corresponding to the qml files I have: TscUi_Main_qml.cpp, TscUi_BottomBar_qml.cpp and TscUi_qmlcache_loader.cpp, but the resource path doesn't include any of this (perhaps correctly). In any case it does not include the qmldir either. > If you're linking the library into the application, you may > just add :/ to your import path so that it's loaded from the qrc file > system right away. Yes, that's the first thing I tried, however when it didn't work I inspected the resource path: QDir dir(":/Tsc"); const auto list = dir.entryInfoList(); for (const auto & entry : list) qDebug() << entry; Which produced only: QFileInfo(:\Tsc\Core) This is the other library, which exports C++ symbols into QML, and which as mentioned works just fine. There's no path for this TscUi target, as I'd've expected. Be aware that some linkers just drop the linkage if > they perceive it to be "unused", though. Yes, perhaps this is the problem, but how do I fix this? What I currently do in the application is to do nothing but link against: qt_add_executable(TscApp main.cpp ) target_compile_definitions(...) target_link_libraries(TscApp PRIVATE Qt6::Core Qt6::Gui Qt6::Quick Qt6::Qml Tsc::Core Tsc::Ui ) qt_add_resources(TscApp "tsc_main" PREFIX / FILES main.qml ) main.qml here I use just as an entry point that I load with: QQuickView view; view.setResizeMode(QQuickView::SizeRootObjectToView); view.setSource(u"qrc:/main.qml"_qs); The qml content is just a trivial instantiation: import Tsc.Ui Main {} Otherwise, if the module ends > up in C:/foo/bar/Tsc/Ui/, then you need to add C:/foo/bar/ to the import > path. > Yes, that's where it ends up, at least that's where the qmldir resides. The executable would be at the root of the application-specific import > path if you were following the recommended directory layout. > I thought I was, but I'm not sure anymore. The application is placed in: <build-path-root>/TscApp The library is in: <build-path-root>/TscUi I've done nothing to change the default layout. On Fri, Jan 14, 2022 at 6:42 AM Günter Schwann <guen...@vikingsoftware.com> wrote: > Hi, > > I did come across some similiar issue. And my solution was to add the > resource as import path. > Hi, I did try this, but this doesn't work as the resource file doesn't contain the qmldir to begin with (see above). I must've messed up something else.
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest