Library can now also be compiled as a qml plugin / module#87
Library can now also be compiled as a qml plugin / module#87Jeruntu wants to merge 2 commits intooKcerG:masterfrom
Conversation
|
Thanks for this PR, small nitpick : why the |
No specific reason, SFPM would be better indeed. If I change it to SFPM will you merge this PR? |
There was a problem hiding this comment.
Thanks for this PR, small nitpick : why the
SFP_xxxxprefix in the CMake file intead ofSFPM_xxx?No specific reason, SFPM would be better indeed. If I change it to SFPM will you merge this PR?
Not sure yet, I plan to compare this PR to PR #80 this weekend since both seems to do the same thing.
What is sure is that I will merge one of the two (modulo some small modifications if needed).
Do you see obvious difference between #80 and your PR? Things not implemented in one or the other?
Both seem to improve the CMake file and add the possibility to build SFPM as a plugin.
| SameMajorVersion | ||
| ) | ||
|
|
||
| set(SFP_INSTALL_PATH "${QML_MODULE_PATH}/QmlSortFilterProxyModel") |
There was a problem hiding this comment.
Why QmlSortFilterProxyModel and not SortFilterProxyModel as already used?
I would prefer SortFilterProxyModel as the default and optionally changeable if you want.
There was a problem hiding this comment.
I would also prefer that, however as stated in my comment, I had a namespace conflict while generating the qmltypes file. That is why I had to change the name.
There was a problem hiding this comment.
In fact qmlplugindump used for generating the *.qmltypes file is the program where I experienced the namespace conflict. Maybe after generating the types file I can change the module name back to SortFilterProxyModel.
|
|
||
| # qml module | ||
| install(TARGETS SortFilterProxyModelPlugin | ||
| RUNTIME DESTINATION ${SFP_INSTALL_PATH} |
There was a problem hiding this comment.
On Linux, RUNTIME installs the .so to plugins/lib/.
LIBRARY seems to produce the correct folder hierarchy. Does it work on Windows?
There was a problem hiding this comment.
It is not really an ordinary plugin but a qml module. I just checked on my windows installation, Qt itself installs qml modules like this:
msvc2019_64/qml/<name_module>
I would like to change it to be the same way.
There are big differences between #80 and my solution. This PR creates a real QML module, not just a shared library. If you build this library as a QML module, the only thing you'll have to do is add the import path to your application. You'll also have autocompletion in QtCreator thanks to the *.qmltypes file. PR #80 creates a shared library. This means you'll have to add a bit of code to make this work.
find_package(SortFilterProxyModel REQUIRED)
...
target_link_libraries(your-target
...
SortFilterProxyModel::SortFilterProxyModel
...
)
QQmlApplicationEngine engine;
...
SortFilterProxyModel::registerQml();
...
engine.load(url); |
I created an extra cmake target
SortFilterProxyModelPluginto build the library as a plugin. This is just a new option and does not affect the otherSortFilterProxyModeltarget. Also the qmake project still works the same as before.I updated the documentation with instructions on how to build and install this library as a qml module. Due to a namespace conflict I had to rename the import name to QmlSortFilterProxyModel, but only for the plugin, not for the existing target.
Using this library as a qml plugin also makes it possible to use it with tools like qmlscene and qhot.