Hello developers,

I am having some trouble with parsing some message data from Python (with 
PyOtherSide) to QML.
The message data comes from the Python module Pynder 
(https://github.com/charliewolf/pynder) and I simply parse the data with a 
for-loop to QML:

Python function:


def getMessageHistory(matchNumber):

# Get the messages from a specific match

messages = matches[matchNumber].messages


# Convert to list

messages = list(messages)


# Send to QML

for i in range(int(len(messages))-1, -1, -1):


pyotherside.send('getMessageHistory', messages[i])


In QML I use a small handler to receive all the data:

setHandler('getMessageHistory', function(messageHistory) {
messagesModel.append({text: messageHistory});
loadingMessages.visible = false;
messagesList.visible = true;
});

QML console:


[D] onReceived:313 - got message from python: 
getMessageHistory,QVariant(PyObjectRef)


[D] onReceived:313 - got message from python: 
getMessageHistory,QVariant(PyObjectRef)


[W] unknown:118 - 
file:///opt/sdk/Sailfinder/usr/share/Sailfinder/qml/pages/MessagesPage.qml:118:31:
 Unable to assign QVariantMap to QString


[W] unknown:118 - 
file:///opt/sdk/Sailfinder/usr/share/Sailfinder/qml/pages/MessagesPage.qml:118:31:
 Unable to assign QVariantMap to QString


[D] onReceived:313 - got message from python: 
getMessageHistory,QVariant(PyObjectRef)


[D] onReceived:313 - got message from python: 
getMessageHistory,QVariant(PyObjectRef)


[D] onReceived:313 - got message from python: 
getMessageHistory,QVariant(PyObjectRef)


[W] unknown:118 - 
file:///opt/sdk/Sailfinder/usr/share/Sailfinder/qml/pages/MessagesPage.qml:118:31:
 Unable to assign QVariantMap to QString


[W] unknown:118 - 
file:///opt/sdk/Sailfinder/usr/share/Sailfinder/qml/pages/MessagesPage.qml:118:31:
 Unable to assign QVariantMap to QString


[W] unknown:118 - 
file:///opt/sdk/Sailfinder/usr/share/Sailfinder/qml/pages/MessagesPage.qml:118:31:
 Unable to assign QVariantMap to QString


The problem is a data conversion between the data from Python and QML. I tried 
to send the data as a string from the Python side and searched on the Internet 
after some information about QvariantMap.
I also tried to send a string instead of the message data and that works fine. 
I saw that QvariantMap has a method: .toString() however I couldn't manage it 
to use it correctly. If necessary I can share my whole project but it's larger 
then 512kb so I can't send it through the mailing list.

Someone who can help?

Regards,
Dylan Van Assche
_______________________________________________
SailfishOS.org Devel mailing list
To unsubscribe, please send a mail to devel-unsubscr...@lists.sailfishos.org

Reply via email to