为QML创建C++插件(下载)

版权声明:本文为博主原创文章,欢迎转载,转载请注明出处 https://blog.csdn.net/MatchYang/article/details/54564462

1. 为QML创建C++插件的官方原文

2.创建插件的过程

qml c

3.创建一个插件的实例:

此实例使用C++调用libexif库以读取图片的Exif信息,插件模块叫QMLExif。先上一个图感受一下效果: 
example

关键代码如下:

...
// 插件类型实例
QMLExif {
    id: exif
    source: "./example.JPG"
    ifd: QMLExif.IFD_EXIF
}
...
TextEdit {
    id: valueEdit
    selectByMouse: true
     parent.width
    height: parent.height
    anchors.centerIn: parent
    horizontalAlignment: TextEdit.AlignLeft
    verticalAlignment: TextEdit.AlignVCenter
    color: "white"
    font.pixelSize: 10
    // 读取Exif信息
    text: exif.getTagValue(tag)
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21

这样,我们在QML中就能实例化一个QMLExif对象以读取图片的Exif信息。

以上插件的代码托管于Github,有需要请参考:QMLExif

https://blog.csdn.net/MatchYang/article/details/54564462

原文地址:https://www.cnblogs.com/findumars/p/9525473.html