Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Sep 2009

    Unhappy Sending signal from QML to C++

    Hi all,

    I know how signal and slot work on QT/C++, but I'm a bit confused about sending signal from QML to C++.

    All the example and tutorial i found on the net and from nokia/qt were mainly focus on:
    1. sending signal from qml to qml and/or using a rectangle with mouse area attached.
    2. none of the example use the Button from import com.nokia.symbian.
    3. focus on transation / java script.... cool stuff...

    What I want to know is the basic stuff...
    sending a signal containing a text in the text field if the button were pressed.
    and processing it in QT part.

    My apps.qml
    import QtQuick 1.0
    import com.nokia.symbian 1.0
    Window {
        id: window
        signal buttonSend_Clicked (string test1text, string text2text)
        Flickable {
            id: flickable1
            contentHeight: 650
            flickableDirection: Flickable.VerticalFlick
            TextField {
                id: inputtest1
                text: ""
            TextField {
                id: inputtest2
                text: ""
            Button {
                id: buttonSend
                text: "SEND"
                onClicked: buttonSend_Clicked(inputtest1.text, inputtest2.text)
    class myapps : public QObject
        private slots:
            void Sendbutton_clicked();
        QObject *rootObject = dynamic_cast<QObject*>(view.rootObject());
        QObject::connect(rootObject, SIGNAL(buttonSend_Clicked()), &myClass, SLOT(Sendbutton_clicked());
    void myapps::Sendbutton_clicked()
    // do some stuff
    Could someone point out my mistake??
    Thank you.

    Thank you

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003

    Re: Sending signal from QML to C++

    Which part of your code is not working ? You basically appear to have the signal defined here, and the maouse area is emitting it.

  3. #3
    Registered User
    Join Date
    Sep 2009

    Re: Sending signal from QML to C++

    AT first I thought it was a mistake in my understanding over QML.
    because I found no direct example of QML using the com.nokia.symbian 1.0 module

    but while waiting on the answer here, and puzzled.
    I finally figure out my typo and mistake.

    my function were myapps, but in signal I cast as myclass.
    rockie cut and paste mistake

    My first thought that my newly understand of QML might result in wrong QML signal code
    I was suspecting this was wrong:
        signal buttonSend_Clicked (string test1text, string text2text)
    and i can't understand the error message meaning in QT very well too
    ............................equal... big headaches

    signal must be defined in main,cpp, not in myapps.cpp.
    I still don't understand why??
    because when main.cpp construct the myapps.cpp, the signal/slot should be constructed too right???
    I can't make it work in myapps.cpp.
    but that's ok, it's not a big deal here.

    thanks for reading this and anwering it
    Last edited by cycnus; 2011-08-13 at 19:08. Reason: +thanks

Similar Threads

  1. QML: disconnect signal object from all slots from QML
    By semlanik in forum [Archived] Qt Quick
    Replies: 1
    Last Post: 2012-03-07, 02:39
  2. How to call/load another QML file from QML ?
    By cadlg in forum [Archived] Qt Quick
    Replies: 5
    Last Post: 2011-07-28, 09:15
  3. Replies: 1
    Last Post: 2008-05-28, 13:02
  4. Problem sending SMS from an application when there is no Signal
    By Archana Muralidhar in forum Mobile Java General
    Replies: 2
    Last Post: 2008-03-14, 10:33

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts