各位猿友好!
问题是这样的:
我在用Qt做的一个抓屏的程序,用到QML中的 grabToImage() 函数,抓屏获得的数据在另外一个控件中显示,这个函数在windows上和安卓模拟器上都可以正常工作,但是在安卓真机上不能正常工作,获取的图像大小正常但是数据却是空的,全透明的。不知道这是什么原因,哪位有这方面的经验?
Qt 中grabWindow()也是一样的结果,在华为荣耀和魅族的机子上都试过,一样的结果!各位救救我啊!
附代码:
import QtQuick 2.4
import QtQuick.Window 2.2
Window {
visible: true
width: Screen.desktopAvailableWidth
height: Screen.desktopAvailableHeight
color: "black"
Item{
anchors.fill: parent
Image {
id: img1
width: 400; height: 400
source: "qrc:/api.png"
Component.onCompleted: {
img1.grabToImage(function(grabResult) {
img2.source = grabResult.url;
showtext.text = String(img2.sourceSize) + img2.paintedWidth + img2.paintedHeight;
})
}
}
Image {
id: img2
width: sourceSize.width; height: sourceSize.height
anchors.right: parent.right
anchors.bottom: parent.bottom
Rectangle {
anchors.fill: parent
border.width: 1
border.color: "white"
color: "#00000000"
}
}
}
Text {
id: showtext
}
}