奥特QT DDS 插件库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Main.qml 2.0KB

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. }
  27. }
  28. }
  29. // Send Data Button
  30. Button {
  31. text: "Send Data"
  32. onClicked: {
  33. if (currentPlugin) {
  34. currentPlugin.publishOnce()
  35. } else {
  36. statusText.text = "No plugin loaded"
  37. }
  38. }
  39. }
  40. // 显示状态信息
  41. Text {
  42. id: statusText
  43. text: "Ready"
  44. color: "black"
  45. }
  46. }
  47. FileDialog {
  48. id: fileDialog
  49. title: "选择插件文件"
  50. nameFilters: ["插件文件 (*.dll *.so)"]
  51. onAccepted: {
  52. var filePath = decodeURIComponent(selectedFile)
  53. currentPlugin = pluginLoader.loadPlugin(filePath)
  54. if (currentPlugin) {
  55. if (currentPlugin.init()) {
  56. statusText.text = "Plugin loaded: " + filePath
  57. } else {
  58. statusText.text = "Failed to initialize plugin"
  59. }
  60. }
  61. }
  62. }
  63. // 处理插件加载错误
  64. Connections {
  65. target: pluginLoader
  66. function onMessagePublished(message, index) {
  67. statusText.text = "Message #" + index + ": " + message
  68. }
  69. }
  70. }