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

issues with register of object instance #2

Closed
Hemi03 opened this issue Jan 28, 2024 · 4 comments
Closed

issues with register of object instance #2

Hemi03 opened this issue Jan 28, 2024 · 4 comments

Comments

@Hemi03
Copy link

Hemi03 commented Jan 28, 2024

I cant register instances under a custom namespace and name.

Env:

  • python 3.11
  • pyside6 6.6.1
  • pylease 3.0.3
  • linux arch kde

if i try to register a instance.

test_model = [p1, p2, p3]
profile_model = ProfilesModel(test_model)
app.register(profile_model, "Profiles", "PyModel")

i get this error in /qmleas/application/register.py

'PySide6.QtCore.QObject.property' called with wrong argument types:
  PySide6.QtCore.QObject.property(int)
Supported signatures:
  PySide6.QtCore.QObject.property(str)
  File "/home/henri/Dokumente/GitHub/qml_playground/.venv/lib/python3.11/site-packages/qmlease/application/register.py", line 198, in __getitem__
    return self.property(item)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/henri/Dokumente/GitHub/qml_playground/.venv/lib/python3.11/site-packages/qmlease/application/register.py", line 104, in register
    if namespace not in self._namespace:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/henri/Dokumente/GitHub/qml_playground/__main__.py", line 100, in main
    app.register(profile_model, "Profiles", "PyModel")
  File "/home/henri/Dokumente/GitHub/qml_playground/__main__.py", line 108, in <module>
    main()
  File "/usr/lib/python3.11/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.11/runpy.py", line 198, in _run_module_as_main (Current frame)
    return _run_code(code, main_globals, None,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'PySide6.QtCore.QObject.property' called with wrong argument types:
  PySide6.QtCore.QObject.property(int)
Supported signatures:
  PySide6.QtCore.QObject.property(str)

it seems like the registration of a instance to a namespace is not realy implemented or expected.

@Hemi03
Copy link
Author

Hemi03 commented Jan 28, 2024

switching to the as C: markt implementation works.

File: /qmleas/application/register.py:104

                # noinspection PyTypeChecker
                qmlRegisterSingletonInstance(__class__, namespace, 1, 0, name, qobj)

@likianta
Copy link
Owner

The latest formal version of qmlease (v3.0.3) doesn't test cover pyside6 v6.5+. The Namespace object works on 6.4 and lower only.

I released a beta version to fix these problems. Please try:

pip install http://likianta.pro:2006/qmlease/qmlease-3.0.4b1-py3-none-any.whl

It should work on the following example:

# test.py
from qmlease import QObject, app

class A(QObject):
    pass

app.register(A(), 'AAA', 'PyAAA')

If no problem, I will publish the formal version v3.0.4 soon possible 😊

@Hemi03
Copy link
Author

Hemi03 commented Jan 29, 2024

It work for me.
I thinks its just a bit confusing that you don't need to import the namespace in qml, like with qmlRegisterSingletonInstance.
Mabye split the register into registerInstance and registerType to make the behavior more clear.

@likianta
Copy link
Owner

likianta commented Feb 1, 2024

It work for me. I thinks its just a bit confusing that you don't need to import the namespace in qml, like with qmlRegisterSingletonInstance. Mabye split the register into registerInstance and registerType to make the behavior more clear.

There was some commented code indicated I had used registerInstance and registerType before (see commit history), but I forget why I dropped it.

I guess the main reason of using Namespace is that it supports "sub" namespaces.

@likianta likianta closed this as completed Feb 1, 2024
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

No branches or pull requests

2 participants