ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #21247
Re: connecting C++ to a QML button
El día Friday, June 17, 2016 a las 09:15:38AM -0400, Michael Terry escribió:
> Err, you should probably keep using QString. Just switch your slot to
> accept a QString object instead of a pointer to one, rather.
Thanks! With this now the three buttons for 'dial', 'answer' and 'status'
call nicely on click the method in MyClass and the rest is to be
implemented there in C++ land.
int main(int argc, char *argv[]) {
QGuiApplication app(argc, argv);
QQuickView v;
QUrl file = (QUrl) "myRoot/home/phablet/baresip-app/baresip.qml";
v.setSource(file);
v.show();
MyClass myClass;
QObject *item = v.rootObject();
QObject *dialButton = item->findChild<QObject*>("dialButton");
QObject::connect(dialButton, SIGNAL(qmlSignal(QString)),
&myClass, SLOT(cppSlot(QString)));
QObject *answerButton = item->findChild<QObject*>("answerButton");
QObject::connect(answerButton, SIGNAL(qmlSignal(QString)),
&myClass, SLOT(cppSlot(QString)));
QObject *statusButton = item->findChild<QObject*>("statusButton");
QObject::connect(statusButton, SIGNAL(qmlSignal(QString)),
&myClass, SLOT(cppSlot(QString)));
return app.exec();
}
I still have two issues to solve in the interface between QML and C++:
1) Depending on the result of 'dialing', the button should change its
label to 'Hangup' when the SIP call was successful. Otherwise it stays
as it is. When 'dial' it pressed the text which was entered in the one
line text field will be send onClick() and not the dummy text. The
latter should be easy. When the call terminates the label of the button
will change back to 'Dial'.
2) From the methods in C++ land a QML TextArea
TextArea {
id: outputBaresip
x: 10; y: 160
width: 520; height: 740
text: ""
}
should be updated (append mode) with the results of the calls etc. See
the attached screen to get the idea.
Having solved this, the minimal SIP phone can be implemted in C++. Calls
are done through sending a command 'd foo@xxxxxxx' to a socket and
reading the result from the socket.
matthias
--
Matthias Apitz, ✉ guru@xxxxxxxxxxx, ⌂ http://www.unixarea.de/ ☎ +49-176-38902045
"Die Verkaufsschlager des Buchmarkts geben Auskunft über den Zustand einer Gesellschaft bzw.
sind, was diese Zeiten angeht, Gradmesser fortschreitenden Schwachsinns. ..." (jW 19.05.2016)
Attachment:
baresip-00.png
Description: PNG image
References