Skip to content

Support for executing SQL on layers #6035

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

Open
3 tasks
gitpydev opened this issue Feb 23, 2025 · 9 comments
Open
3 tasks

Support for executing SQL on layers #6035

gitpydev opened this issue Feb 23, 2025 · 9 comments

Comments

@gitpydev
Copy link

gitpydev commented Feb 23, 2025

What is the bug or the crash? What were your expectations and what actually happened?

AFAIK, v3.5.0's Plugin System is including qt6's qtdeclarative module which is with QtQuick.Dialogs Module and QtQuick.Controls Module, but only the latter could be imported in a plugin's main.qml file, and the Dialogs one could not be imported normally.

Steps to reproduce the issue

Write a main.qml with QtQuick.Dialogs imported, and this plugin wouldn't load normally.

Version

3.5.0

Operating system name

Android

Operating system version

10

Reinstall QField

  • I have a fresh install of the latest QField version, but the problem persists.
  • Problem can be reliably reproduced, doesn't happen randomly.
  • Problem happens with all files and projects, not only some files or projects.

Additional context

No response

@nirvn
Copy link
Member

nirvn commented Feb 23, 2025

@gitpydev , we don't ship with that QML module (yet), I've marked this as an enhancement request. Which item were you interested in?

@gitpydev
Copy link
Author

gitpydev commented Feb 23, 2025

@gitpydev , we don't ship with that QML module (yet), I've marked this as an enhancement request. Which item were you interested in?

Uh huh, perhaps I need more code reading, I thought the whole qtdeclarative submodule had been included.
I am implementing a plugin in android platform which would read gpkg file in for further processing, and try to utilize the FileDialog Component in QtQuick.Dialogs Module to do it.
I've checked qt's doc and confirmed that in qt6 it already supports android platform, so I wrote the import line in the plugin main.qml file, and find it not working.

@nirvn
Copy link
Member

nirvn commented Feb 23, 2025

@gitpydev , that module was added in Qt 6.2 and doesn't appear to be built by default (https://github.com/qt/qtdeclarative/blob/63646efa485b8f5ef00c1e7dadbfa69bb157f05f/src/CMakeLists.txt#L72-L74), at least not on vcpkg.

@gitpydev
Copy link
Author

gitpydev commented Feb 23, 2025

@gitpydev , that module was added in Qt 6.2 and doesn't appear to be built by default (https://github.com/qt/qtdeclarative/blob/63646efa485b8f5ef00c1e7dadbfa69bb157f05f/src/CMakeLists.txt#L72-L74), at least not on vcpkg.

I see, plenty of helps for me, thanks a lot for nirvn's nice replies.

Before trying to utilize this local file accessing capability provided by Qml, I also tried to utilize the built-in capability provided by QField itself, aka the platformUtilityies.import* Q_INVOKABLE API, which were used by importing local project files etc., I could invoke it successfully in a plugin's main.qml, but finally found it not general enough for local file accessing purpose, more like for dedicated purpose. Anyway, QField is really a great open source project, praising.

@nirvn nirvn changed the title Isn't QField's Qml Plugin System supporting QtQuick.Dialog Module? Support for QtQuick.Dialog module for QField plugins Feb 23, 2025
@gitpydev
Copy link
Author

gitpydev commented Feb 23, 2025

By the way, will QField plugins consider adding support for QtQuick.LocalStorage Module? It would be convenient utilizing this module for sqlite db accessing which is also suitable for gpkg files.

@m-kuhn
Copy link
Member

m-kuhn commented Feb 28, 2025

There's also QfDialog to show dialogs, do you need access to system dialogs via QtQuick.Dialogs, if yes, which one specifically? Note that especially file system access is very limited on android and ios.

Are you confident that you'll be able to interact with gpkg through QtQuick.LocalStorage in a satisfying way?
Normally interaction with gpkg's is best done through spatially aware libraries like gdal and I don't see this possible.
Depending on the needs another approach could be envisioned that allows executing SQL on a loaded layer through its data provider.

@gitpydev
Copy link
Author

gitpydev commented Mar 1, 2025

There's also QfDialog to show dialogs, do you need access to system dialogs via QtQuick.Dialogs, if yes, which one specifically? Note that especially file system access is very limited on android and ios.

Are you confident that you'll be able to interact with gpkg through QtQuick.LocalStorage in a satisfying way?
Normally interaction with gpkg's is best done through spatially aware libraries like gdal and I don't see this possible.
Depending on the needs another approach could be envisioned that allows executing SQL on a loaded layer through its data provider.

Thanks m-kuhn for your reply.

Generally speaking, I just want to access local file in qfield's qml plugin code in android platform, after searching for related API in qfield itself, I couldn't find one for this purpose. So I put my eyes on the Qml's FileDialog Component which is provided by QtQuick.Dialog Module.

So actually I am not about to show dialogs but find ways to access local file.

It's true that managing gpkg file with plain QtQuick.LocalStorage which is for general sqlite db file won't be a satisfying way, but at least providing a convenient way to acess it compared to reading the file content out and parsing it manually as sqlite/gpkg format.

@m-kuhn
Copy link
Member

m-kuhn commented Mar 17, 2025

@gitpydev I believe we would ideally look for exposing qgis-native API's to execute SQL on the layer source (similar to what with the db manager / browser can be done in QGIS). This way we will have proper access to the providers of loaded layers which should be the most powerful, safe and future proof approach.

@HeatherHillers
Copy link

@m-kuhn Having SQL access to the layer source would add lots of flexibility for plugin development. I would love to have that!

@m-kuhn m-kuhn changed the title Support for QtQuick.Dialog module for QField plugins Support for executing SQL on layers Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants