Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

When used through QWebChannel, .state always returns null #61

Open
Ivshti opened this issue Aug 24, 2016 · 4 comments
Open

When used through QWebChannel, .state always returns null #61

Ivshti opened this issue Aug 24, 2016 · 4 comments
Labels

Comments

@Ivshti
Copy link

Ivshti commented Aug 24, 2016

Here's some sample code:

main.qml

Component.onCompleted: function() {
webView.webChannel.registerObject( 'vlcPlayer', vlcPlayer );
}

index.html

<script src='qrc:///qtwebchannel/qwebchannel.js'>
<script>
new QWebChannel(qt.webChannelTransport, function(channel) {
        var vlc = channel.objects.vlcPlayer;
        setInterval(function() { console.log(vlc.state) }, 2000); // always null
        setInterval(function() { console.log(vlc.time) }, 2000); // proper integer value
});
</script>

Is the issue in the way Qt translates enums? It should be OK in theory.

Qt WebEngine 1.3
Qt WebChannel 1.0
QmlVlc 0.1

@Ivshti
Copy link
Author

Ivshti commented Aug 24, 2016

I did hack it by replacing

Q_PROPERTY( State state READ get_state NOTIFY stateChanged )

with

Q_PROPERTY( unsigned state READ get_state NOTIFY stateChanged )

I assume casting the enum to unsigned is a hack here, and QWebChannel should work just fine with the enum in the first place. I'll let you @RSATom figure out the clean solution

@RSATom RSATom added the bug label Aug 24, 2016
@RSATom
Copy link
Owner

RSATom commented Aug 24, 2016

Thanks, I'll look.

@Ivshti
Copy link
Author

Ivshti commented Nov 22, 2016

@RSATom any updates on this? It kind of blocks some stuff

@RSATom
Copy link
Owner

RSATom commented Nov 23, 2016

sorry, not yet

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

No branches or pull requests

2 participants