main.qml 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import QtQuick 2.6
  2. import QtQuick.Window 2.2
  3. import gfa.plugins.qml.net 1.0
  4. Window {
  5. visible: true
  6. width: 640
  7. height: 480
  8. title: qsTr("Hello World")
  9. Text {
  10. id: idIpAddr
  11. x: 5
  12. y: 40
  13. color: "blue"
  14. font.pixelSize: 14
  15. text: idItf.interfaces[0].ipAddress.address
  16. }
  17. NetInterfaces {
  18. id: idItf
  19. // itfFilterName: "eth0"
  20. itfFilterAF: Interface.AF_Inet
  21. itfFilterMethod: Interface.IM_Static | Interface.IM_Manual
  22. onSigError:
  23. {
  24. console.error(msg);
  25. }
  26. }
  27. MouseArea {
  28. anchors.fill: parent
  29. onClicked:
  30. {
  31. if(idItf.filteredInterfaces.length > 0)
  32. {
  33. idItf.filteredInterfaces[0].ipAddress.address = "192.168.0.256";
  34. idItf.filteredInterfaces[0].ipAddress.address = "155.18.2.156";
  35. idItf.filteredInterfaces[0].ipAddress.b0 = 255;
  36. console.log(idItf.filteredInterfaces[0].ipAddress.address);
  37. }
  38. else
  39. {
  40. console.warn("No interface found!");
  41. }
  42. idItf.itfFilterMethod |= Interface.IM_Dhcp;
  43. // idItf.itfFilterName = "eth1";
  44. idItf.itfFilterMethod &= ~Interface.IM_Static;
  45. idItf.filteredInterfaces[0].af = Interface.AF_Unknown;
  46. // idItf.saveAs("/home/wrk/share/gfanet/libgfanet/res/testitf");
  47. }
  48. }
  49. }