Newb needs help integrating C with QML using Qt 5.2



  • Hi all. I'm a newb in every sense of the word, so if it seems I'm asking this question incorrectly, bear with me...

    I'm a hardware designer that was dropped into the position of software and had to learn basic C and C++ in the last 9 months. At the moment I am attempting to write a UDP portal terminal for Windows (I'm operating on Windows 7) to send specific UDP commands to my embedded software, and display what comes back in a text window. So far, I've figured out how to create the GUI by dragging and dropping buttons, and labeling them. But my biggest question is: how do I integrate them into C++/C, or do I need to? I have done some reading in a few of the documentation pages, but I'm getting the feeling that I'm missing something...

    I had planned on using the QUdpSocket class with this project. For instance, if I have the button:
    @
    Button {
    id: step_DAC
    x: 106
    y: 408
    text: "DAC Step"
    }@

    All I want is for it to send 0x0D4C via UDP to my machine. so would I set up the button as follows?

    @ Button {
    id: step_DAC
    x: 106
    y: 408
    text: "DAC Step"
    signal clicked
    onClicked {qint64 QUdpSocket::writeDatagram(const char * data, qint64 size, const QHostAddress & address, quint16 port);} // with all the data filled in of course...
    }@

    Is it that simple or am I missing some link between the signal, slot, and C code...?

    As for returning the text to the text area, I'm not sure about how to do that... If I receive a UDP packet, say there's a pending datagram, and I read it in with @"qint64 QUdpSocket::readDatagram(char * data, qint64 maxSize, QHostAddress * address = xx, quint16 * port = xx)"@ - I open "data" and have a lookup table of text for each code that comes in on that packet, I want to output that text to the text box that I've created. I'm not sure exactly how to update that textbox.

    Sorry if these questions sound primitive, this is not my area of expertise, but needs to be asap. This is all a little abstract for me. Once I get past a certain layer of abstraction, I can figure out the rest. Thanks all for your time and help!!!



  • You can check documentation for "here":http://qt-project.org/doc/qt-5.0/qtqml/qtqml-cppintegration-topic.html. This will surely help you.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.