Re: [Interest] qt_add_qml_module and not embedding QML files

2022-11-02 Thread Ulf Hermann via Interest
2. The app is primarily widgets, but we use QML inside QQuickView, 
inside container widgets. So when the app starts 3 or 4 QML engines are 
created.


That is a problem. The preview can only handle a single QML engine so 
far. You should see the following error message:


" QML engines available. We cannot decide which one should load the 
component."

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-11-02 Thread Benjamin TERRIER
On Wed, 2 Nov 2022 at 09:32, Ulf Hermann via Interest <
interest@qt-project.org> wrote:

>
> Can you try to construct a minimal example that reproduces the problem
> and create a bug report?


> One significant difference between QML debugger and QML preview is that
> the debugger uses a TCP connection while the preview uses a local
> socket. The QML profiler also uses a local socket. Does that work?
> ___
>
>
The QML profiler works fine.
I was able to reproduce the preview being stuck at connecting on another PC.

When I tried with basic examples, the preview works fine,  so it needs some
investigation before reproducing it with a minimal example.

The 2 main points that could be relevant are:
1. I use Qt WebEngine widgets, it might be nothing, but the fact that Qt
WebEngine does not work in the nanobrowser example when using qml preview
is suspicious.
2. The app is primarily widgets, but we use QML inside QQuickView, inside
container widgets. So when the app starts 3 or 4 QML engines are created.

I'll try to do some tests around that when I have some free time in the
next few days.
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-11-02 Thread Ulf Hermann via Interest

You probably have to enable QML debugging and profiling in the build
and run settings.

It is already, and it works.
I can set breakpoints in QML and it works as expected.


Can you try to construct a minimal example that reproduces the problem 
and create a bug report?


One significant difference between QML debugger and QML preview is that 
the debugger uses a TCP connection while the preview uses a local 
socket. The QML profiler also uses a local socket. Does that work?

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-11-01 Thread Benjamin TERRIER
On Tue, 1 Nov 2022 at 09:42, Ulf Hermann via Interest <
interest@qt-project.org> wrote:

> > I did not know about that, it looks nice.
> > But... it does not work with my application, it gets stuck at "QML
> > Debugger: Connecting to socket"
>
> You probably have to enable QML debugging and profiling in the build and
> run settings.
>
>
It is already, and it works.
I can set breakpoints in QML and it works as expected.
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-11-01 Thread Ulf Hermann via Interest

I did not know about that, it looks nice.
But... it does not work with my application, it gets stuck at "QML 
Debugger: Connecting to socket"


You probably have to enable QML debugging and profiling in the build and 
run settings.

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-10-31 Thread Benjamin TERRIER
On Mon, 31 Oct 2022 at 16:29, Ulf Hermann via Interest <
interest@qt-project.org> wrote:

> > I cannot use qmlpreview, as I usually need to have the full application
> > running.
>
> You can run any application through QML preview. In Qt Creator (in
> contrast to Qt Design Studio), the option is a bit hidden: There is a
> "QML Preview" Option in the build menu. Use that to start the
> application. You can then right click on any QML file in the project
> tree and "Preview file".
>
>
>
I did not know about that, it looks nice.
But... it does not work with my application, it gets stuck at "QML
Debugger: Connecting to socket"
I tried with the nanobrowser example, the qml reload works but the Qt
WebEngine part does not work.

Also I like to have the option to only reload the QML after triggering a
build, or at least after saving all files, not every time I type a
character.

As it is, it is not usable for me for the main project I work on.
I'll use it for smaller projects though.

Regards

Benjamin
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-10-31 Thread Ulf Hermann via Interest
I cannot use qmlpreview, as I usually need to have the full application 
running.


You can run any application through QML preview. In Qt Creator (in 
contrast to Qt Design Studio), the option is a bit hidden: There is a 
"QML Preview" Option in the build menu. Use that to start the 
application. You can then right click on any QML file in the project 
tree and "Preview file".


best regards,
Ulf
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-10-31 Thread Benjamin TERRIER
On Mon, 31 Oct 2022 at 10:48, Ulf Hermann via Interest <
interest@qt-project.org> wrote:

> > Is there a way to not embed QML files into the Qt resource system when
> > using qt_add_qml_module() ?
>
> We can only pre-compile files embedded into the resource file with
> qmlcachegen. That's why we strongly recommend using the resource file
> system. You can, of course still manually write your qmldir files and
> handle the build process manually like in Qt5. It's definitely not
> recommended, though.
>
This would only be used in debug/development mode, with qml
compilation/cachegen disabled.


> > Or at least, not generate the "prefer :/..." line in the qmldir file ?
>
> The "prefer" line is vital. If you drop it, the module still looks like
> it would use the pre-compiled code in the qrc system with all the nice
> optimizations you get from compiling functions and bindings to C++. Yet,
> the QML engine will actually load the files from the host file system
> and ignore all of the goodies. Don't do this.
>

I do not want the goodies in this case.
When building in release mode, of course I still want the goodies.
I just want to disable them in debug mode.


>
> > Having the prefer line makes it impossible to load QML files from disk,
> > preventing any kind of live reloading of QML.
>
> If you're using Qt Creator's "QML preview" feature, it should try to
> match your qrc paths to the source paths in your project. As the engine
> then runs in debug mode, it can live-replace the contents of the QML
> files. There is also a command line "qmlpreview" tool.
>
> If the QML preview feature somehow got broken in Qt6, please file a bug
> report. It is mostly used by Qt Design Studio, and Qt Design Studio
> likes to use "qmlproject" projects without cmake.
>
>
I cannot use qmlpreview, as I usually need to have the full application
running.


On Mon, 31 Oct 2022 at 10:48, Ulf Hermann via Interest <
interest@qt-project.org> wrote:

> > Is there a way to not embed QML files into the Qt resource system when
> > using qt_add_qml_module() ?
>
> We can only pre-compile files embedded into the resource file with
> qmlcachegen. That's why we strongly recommend using the resource file
> system. You can, of course still manually write your qmldir files and
> handle the build process manually like in Qt5. It's definitely not
> recommended, though.
>
> > Or at least, not generate the "prefer :/..." line in the qmldir file ?
>
> The "prefer" line is vital. If you drop it, the module still looks like
> it would use the pre-compiled code in the qrc system with all the nice
> optimizations you get from compiling functions and bindings to C++. Yet,
> the QML engine will actually load the files from the host file system
> and ignore all of the goodies. Don't do this.
>
> > Having the prefer line makes it impossible to load QML files from disk,
> > preventing any kind of live reloading of QML.
>
> If you're using Qt Creator's "QML preview" feature, it should try to
> match your qrc paths to the source paths in your project. As the engine
> then runs in debug mode, it can live-replace the contents of the QML
> files. There is also a command line "qmlpreview" tool.
>
> If the QML preview feature somehow got broken in Qt6, please file a bug
> report. It is mostly used by Qt Design Studio, and Qt Design Studio
> likes to use "qmlproject" projects without cmake.
>
> best regards,
> Ulf
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-10-31 Thread Ulf Hermann via Interest
Is there a way to not embed QML files into the Qt resource system when 
using qt_add_qml_module() ?


We can only pre-compile files embedded into the resource file with 
qmlcachegen. That's why we strongly recommend using the resource file 
system. You can, of course still manually write your qmldir files and 
handle the build process manually like in Qt5. It's definitely not 
recommended, though.



Or at least, not generate the "prefer :/..." line in the qmldir file ?


The "prefer" line is vital. If you drop it, the module still looks like 
it would use the pre-compiled code in the qrc system with all the nice 
optimizations you get from compiling functions and bindings to C++. Yet, 
the QML engine will actually load the files from the host file system 
and ignore all of the goodies. Don't do this.


Having the prefer line makes it impossible to load QML files from disk, 
preventing any kind of live reloading of QML.


If you're using Qt Creator's "QML preview" feature, it should try to 
match your qrc paths to the source paths in your project. As the engine 
then runs in debug mode, it can live-replace the contents of the QML 
files. There is also a command line "qmlpreview" tool.


If the QML preview feature somehow got broken in Qt6, please file a bug 
report. It is mostly used by Qt Design Studio, and Qt Design Studio 
likes to use "qmlproject" projects without cmake.


best regards,
Ulf
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-10-30 Thread Benjamin TERRIER
On Sat, 29 Oct 2022 at 12:13, Benjamin B (BBenj) 
wrote:

> Hello,
>
> I can't answer your question specifically, but if you're using Qt 6 you
> may want to look into QQmlEngine::addUrlInterceptor to handle live reloads.
>  I don't think Qt 5 has something equivalent.
>

Qt 5 had QQmlEngine::setUrlInterceptor().
It seems undocumented, but the class QQmlAbstractUrlInterceptor was
documented.


> You can look for runtimeqml on GitHub for a use of it (disclaimer- I'm the
> author and while it works for me it was not extensively tested ;-)
> https://github.com/GIPdA/runtimeqml ).
>
>
Remapping all qrc files to the filesystem path seems a bit overkill when
using qt_add_qml_module() as we already have a perfectly good on disk QML
module that the engine can use.
Also in this case the qrc files are generated by CMake, I am not sure I can
easily get the names of the qrc files.

In the ends it is really just the "prefer" line in the qmldir that makes it
impossible to use the on disk qml modules.
For now I've found a solution, I just run a "sed" command to comment the
"prefer" line in all the qmldir at the end of CMake configuration. It's a
bit ugly though, I would prefer to set an option in qt_add_qml_module().

Side note, I've also found that the URL interceptor does not work when QML
files are compiled with cachegen (which is the default when using
qt_add_qml_module).
I guess that is because the components are always in cache and the QML
engine never needs to load them by URL.

Cheers
Benjamin
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] qt_add_qml_module and not embedding QML files

2022-10-29 Thread Benjamin B (BBenj)
Hello,

I can't answer your question specifically, but if you're using Qt 6 you may 
want to look into QQmlEngine::addUrlInterceptor to handle live reloads. I don't 
think Qt 5 has something equivalent.
You can look for runtimeqml on GitHub for a use of it (disclaimer- I'm the 
author and while it works for me it was not extensively tested ;-) 
https://github.com/GIPdA/runtimeqml  ).

Benjamin



> Le 27 oct. 2022 à 23:13, Benjamin TERRIER  a écrit :
> 
> Hi,
> 
> Is there a way to not embed QML files into the Qt resource system when using 
> qt_add_qml_module() ?
> 
> Or at least, not generate the "prefer :/..." line in the qmldir file ?
> 
> Having the prefer line makes it impossible to load QML files from disk, 
> preventing any kind of live reloading of QML.
> 
> Thanks
> 
> Benjamin
> 
> 
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest