Program Listing for File minimal_example.qml

Return to documentation for file (src/qml/example/minimal_example.qml)

import QtQuick 2.11
import QtQuick.Window 2.11
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.4
import QtQuick.Controls.Material 2.4
import QtCharts 2.2

import fkin.Dds 1.0

ApplicationWindow {
  id: window;
  title: qsTr("Minimal QML example");
  width: 480;
  height: 200;
  visible: true;

  QtToDds {
    id: ddsParticipant;
    readonly property int domain: 0;

    Component.onCompleted: {
      init(domain);

      ddsSubscriber.init(ddsParticipant, "testBit");
      ddsPublisher.init(ddsParticipant, "testBit", aSwitch.checked, true);
    }
  }

  GridLayout {
    anchors.fill: parent;
    anchors.margins: 20;
    columns: 2;

    Label { text: "DDS bit publisher"; }

    Switch {
      id: aSwitch;
      text: qsTr("Send with DDS");
      checked: true;
      onToggled: {
        console.log("Switch signal is: " + ddsPublisher.signal);
      }

      DdsBitPublisher {
        id: ddsPublisher;
        signal: aSwitch.checked;
      }
    }
    Label { text: "DDS bit subscriber"; }

    Switch {
      id: aSwitchInput;
      text: qsTr("Received from DDS");
      checked: ddsSubscriber.signal;

      DdsBitSubscriber {
        id: ddsSubscriber;
      }
    }
  }
}