奥特QT DDS 插件库
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

84 lines
2.1KB

  1. import QtQuick
  2. import QtQuick.Controls
  3. import QtQuick.Dialogs
  4. import QtQuick.Layouts
  5. Window {
  6. width: 640
  7. height: 480
  8. visible: true
  9. title: qsTr("AuseftDDSPlugTest")
  10. property var currentPlugin: null
  11. ColumnLayout {
  12. anchors.centerIn: parent
  13. spacing: 20
  14. // Load Plugin Button
  15. Button {
  16. text: "Load Plugin"
  17. onClicked: fileDialog.open()
  18. }
  19. // Configure Plugin Button
  20. // Button {
  21. // text: "Configure Plugin"
  22. // enabled: currentPlugin !== null
  23. // onClicked: {
  24. // if (currentPlugin) {
  25. // currentPlugin.config()
  26. // } else {
  27. // statusText.text = "No plugin loaded"
  28. // }
  29. // }
  30. // }
  31. // Send Data Button
  32. Button {
  33. text: "Send Data"
  34. onClicked: {
  35. if (currentPlugin) {
  36. currentPlugin.publishOnce()
  37. } else {
  38. statusText.text = "No plugin loaded"
  39. }
  40. }
  41. }
  42. // 显示状态信息
  43. Text {
  44. id: statusText
  45. text: "Ready"
  46. color: "black"
  47. }
  48. }
  49. FileDialog {
  50. id: fileDialog
  51. title: "选择插件文件"
  52. nameFilters: ["插件文件 (*.dll *.so)"]
  53. onAccepted: {
  54. var filePath = decodeURIComponent(selectedFile)
  55. currentPlugin = pluginLoader.loadPlugin(filePath)
  56. if (currentPlugin) {
  57. if (currentPlugin.init()) {
  58. statusText.text = "Plugin loaded: " + filePath
  59. } else {
  60. statusText.text = "Failed to initialize plugin"
  61. }
  62. }
  63. }
  64. }
  65. // 处理插件加载错误
  66. Connections {
  67. target: pluginLoader
  68. function onMessagePublished(message, index) {
  69. statusText.text = "Message #" + index + ": " + message
  70. }
  71. }
  72. }