我想在图像上绘制文本。我使用此代码,但是在图像上看不到任何文本。
void ImageSaver::save(const QString &path) const {
QImage image(img_);
QPainter p(&image);
p.setPen(QPen(Qt::red));
p.setFont(QFont("Times", 12, QFont::Bold));
p.drawText(image.rect(), Qt::AlignCenter, "Text");
image.save(path);
}
Run Code Online (Sandbox Code Playgroud) 我正在用相机拍电影.
我想使用滑块缩放视频,如谷歌地图缩放.
我在SO上发现了另一个问题但是建议的解决方案适用于click,而我想为滑块开发一个解决方案.
我编写的代码无法正常工作.我没有发现错误,但视频大小会非常大,然后我看不到视频.
我尝试将digitalZoom设置为相机,但我有这个错误:
相机不支持缩放..我知道我的相机不支持"DigitalZoom"和"OpticalZoom".我想找到一种方法来放大从相机拍摄的视频.
我的相机是dino ccd.
对不起朋友,我无法添加评论,我有这样的错误:"你必须有50个评论的声誉".
VideoOutput {
id: viewfinder
source: camera
anchors.fill: parent
focus : true
transform: [
Scale {
id: zoomScale
},
Translate {
id: zoomTranslate
}
]
//Keys.onLeftPressed: viewfinder.seek(viewfinder.position - 5000)
//Keys.onRightPressed: viewfinder.seek(viewfinder.position + 5000)
MouseArea {
anchors.fill: parent
acceptedButtons: Qt.AllButtons
onClicked: {
var zoomIn = mouse.button === Qt.LeftButton;
zoomScale.origin.x = mouse.x;
zoomScale.origin.y = mouse.y;
}
}
Slider {
id:zoomVideo
orientation: Qt.Vertical
minimumValue: 0
maximumValue: 100
stepSize: 10
onValueChanged: …Run Code Online (Sandbox Code Playgroud) 我想绘制一个有4个不等长度的边和能够拖动它的顶点的形状.当我拖动顶点时,连接到它的侧面应相应调整大小.
我在SO上发现了另一个问题但是提出的解决方案适用于Rectangles而我希望开发一种梯形形状的解决方案,如下图所示:

我目前的代码:
property var selection: undefined
Image {
id: image1
anchors.fill: parent
source: "1.jpg"
MouseArea {
anchors.fill: parent
onClicked: {
if(!selection)
selection = selectionComponent.createObject(parent, {"x": parent.width / 4, "y": parent.height / 4, "width": parent.width / 2, "height": parent.width / 2})
}
}
}
Component {
id: selectionComponent
Rectangle {
id: selComp
border {
width: 2
color: "steelblue"
}
color: "#354682B4"
property int rulersSize: 18
MouseArea { // drag mouse area
anchors.fill: parent
drag{ …Run Code Online (Sandbox Code Playgroud)