[GH-ISSUE #84] Add support for QQmlPropertyValueSource #53

Open
opened 2026-05-05 11:01:53 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @cbelyaev on GitHub (Dec 12, 2018).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/84

Hi

How can I help with implementing this?
http://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html#property-value-sources

Originally created by @cbelyaev on GitHub (Dec 12, 2018). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/84 Hi How can I help with implementing this? http://doc.qt.io/qt-5/qtqml-cppintegration-definetypes.html#property-value-sources
gitea-mirror added the
todo
help wanted
labels 2026-05-05 11:01:53 -06:00
Author
Owner

@pauldotknopf commented on GitHub (Dec 12, 2018):

That would be an awesome add! I think its implementation should be straightforward as well.

public class QmlProperty
{
    // PInvoke for QQmlProperty: http://doc.qt.io/qt-5/qqmlproperty.html
}


public interface IQmlPropertyValueSource
{
    void setTarget(QmlProperty target);
}

public class MyNetObject : IQmlPropertyValueSource
{
    private QmlProperty _target;

    public MyNetObject()
    {
        // Maybe create a timer to update the "_target" (if not null)
        // at periodic intervals?
    }
    
    public void setTarget(QmlProperty target)
    {
        _target = target;
    }
}

Then, we'd add the QQmlPropertyValueSource base to the existing NetValue (here) type, which will implement the QQmlPropertyValueSource::setTarget(QQmlProperty) method and send it to .NET.

We'd also have to extend the NetTypeInfo (here) to have a bool IsPropertyValueSource that will be used in NetValue to log if someone is trying to use .NET Object as a value source and it doesn't implement the required IQmlPropertyValueSource .NET interface.

<!-- gh-comment-id:446487476 --> @pauldotknopf commented on GitHub (Dec 12, 2018): That would be an awesome add! I think its implementation should be straightforward as well. ``` public class QmlProperty { // PInvoke for QQmlProperty: http://doc.qt.io/qt-5/qqmlproperty.html } public interface IQmlPropertyValueSource { void setTarget(QmlProperty target); } public class MyNetObject : IQmlPropertyValueSource { private QmlProperty _target; public MyNetObject() { // Maybe create a timer to update the "_target" (if not null) // at periodic intervals? } public void setTarget(QmlProperty target) { _target = target; } } ``` Then, we'd add the ```QQmlPropertyValueSource``` base to the existing ```NetValue``` ([here](https://github.com/qmlnet/qmlnet/blob/e0a769321ef435bdcd41828a5711041a6eb626fe/src/native/QmlNet/QmlNet/qml/NetValue.h)) type, which will implement the ```QQmlPropertyValueSource::setTarget(QQmlProperty)``` method and send it to .NET. We'd also have to extend the ```NetTypeInfo``` ([here](https://github.com/qmlnet/qmlnet/blob/275bff1c84b98e00618fa83880eb1307492e3dbf/src/native/QmlNet/QmlNet/types/NetTypeInfo.h)) to have a ```bool IsPropertyValueSource``` that will be used in ```NetValue``` to log if someone is trying to use .NET Object as a value source and it doesn't implement the required ```IQmlPropertyValueSource``` .NET interface.
Author
Owner

@pauldotknopf commented on GitHub (Dec 12, 2018):

I'm marking this issue as "todo", as I will likely implement it at some point in the future.

However, I'm open to pull requests. I think this would be perfect for new comers. It's not too big of a change and it exposes you to a comfortable amount of the internals.

<!-- gh-comment-id:446487920 --> @pauldotknopf commented on GitHub (Dec 12, 2018): I'm marking this issue as "todo", as I will likely implement it at some point in the future. However, I'm open to pull requests. I think this would be perfect for new comers. It's not too big of a change and it exposes you to a comfortable amount of the internals.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#53
No description provided.