Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library can now also be compiled as a qml plugin / module #87

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Jeruntu
Copy link
Contributor

@Jeruntu Jeruntu commented Jan 22, 2021

I created an extra cmake target SortFilterProxyModelPlugin to build the library as a plugin. This is just a new option and does not affect the other SortFilterProxyModel target. 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.

@oKcerG
Copy link
Owner

oKcerG commented May 3, 2021

Thanks for this PR, small nitpick : why the SFP_xxxx prefix in the CMake file intead of SFPM_xxx?

@Jeruntu
Copy link
Contributor Author

Jeruntu commented May 7, 2021

Thanks for this PR, small nitpick : why the SFP_xxxx prefix in the CMake file intead of SFPM_xxx?

No specific reason, SFPM would be better indeed. If I change it to SFPM will you merge this PR?

Copy link
Owner

@oKcerG oKcerG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR, small nitpick : why the SFP_xxxx prefix in the CMake file intead of SFPM_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")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why QmlSortFilterProxyModel and not SortFilterProxyModel as already used?
I would prefer SortFilterProxyModel as the default and optionally changeable if you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Linux, RUNTIME installs the .so to plugins/lib/.
LIBRARY seems to produce the correct folder hierarchy. Does it work on Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Jeruntu
Copy link
Contributor Author

Jeruntu commented May 31, 2021

Thanks for this PR, small nitpick : why the SFP_xxxx prefix in the CMake file intead of SFPM_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.

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.

  1. In CMake:
find_package(SortFilterProxyModel REQUIRED) 
...
target_link_libraries(your-target
...
SortFilterProxyModel::SortFilterProxyModel
...
)
  1. In main.cpp:
QQmlApplicationEngine engine;
...
SortFilterProxyModel::registerQml();
...
engine.load(url);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants