I am trying to create an outline of a path in QML. I read that QPainterPathStroker is able to do this, but it is not in QML. What is the QML equivalent of QPainterPathStroker?
Canvas QML type is the closest one. You can see Canvas examples here.
Related
Is there a way to simply tell the object not to repaint? For example so that a Rectangle object will not change color after changing color property.
There's no simple way to do this from QML. I'm not sure that it's even possible to do this in QML; it may be possible in C++.
You can use Canvas instead, which gives you control over when rendering happens.
I am trying to import SVG as QGraphicsItem in QGraphicsScene and vice versa.
Is there a way to do it with QSvgGenerator, QSvgRenderer or have to build my own method for that.
Also, can't find builtin method for the XML(SVG) representation. Please help.
There is a diagram which I have drawn with QPainter.
How do I diaplay it in QML's Rectangle?
That diagram will get updated on the runtime.
The question is a bit vague.
Do you have the diagram in a QImage or a QPixmap? Then you can use image providers to expose the diagram to QML, and draw it into a Image element.
Do you have the code that uses a QPainter to draw it, and want to make a QML element that uses such code? In that case, subclass QDeclarativeItem (in Qt Quick 1) or QQuickPaintedItem (Qt Quick 2), override their paint() methods and do the drawing there. You can then register the new type in the QML engine, so you can use a Diagram type in your QML files.
I'm trying to get an alpha-blending effect in QML with a video in RGBA.
Now the problem is that the Video Item supplied by QtMultimedia actualy opens an overlaying window in the QtQuick scene, so I don't think it's possible to alpha-blend other QML elements with the Video element (I sure hope I'm wrong, but I can't find a solution).
So another way would be rendering a video myself in a class that inherits from QQuickItem, in the updatePaintNode method.
Has anyone seen anything like this before? Is it even possible if the guys behind QtMultimedia couldn't achieve it?
Can I maybe change the background of the MediaPlayer element, maybe to be transparent or just a color in QML?
So far I was thinking about QAbstractVideoSurface and QVideoFrame but I have no idea how to render it onto the QSG, or even how should the GeometryNode look for a video.
The best solution would be to get the alpha-blending with other QML Elements for example in:
Rectangle {
width: 1024
height: 768
color: "yellow"
focus: true
Video {
id: video
anchors.fill: parent
source: "alpha-video.mov"
autoPlay: true
}
}
Thanks in advance!
I tried a few things, but in the end I used the Qt example called VideoWidget that uses QAbstractVideoSurface and QVideoFrame, and painted the frames in a QQuickPaintedItem, using MediaPlayer to load the data from QML.
It's important to put ARGB32 on top of the QList that describes the supported pixel formats in the QAbstractVideoSurface, unfortunately the Qt logic is that they take the first availibe format and that's why the native Video element doesn't show the alpha channel (it plays the video in RGB32, either that or it's a thing with the overlaying window in the native element instead of painting it in the QtQuick Scene Graph).
I simply want to paint a 1 pixel dot on a specific point on the screen. Is there anyway to do that? In QML or cpp?
Rectangle QML item should works good for you: http://qt-project.org/doc/qt-4.8/qml-rectangle.html
If you need to draw something more specific and more flexible, then you can customize QDeclarativeItem in C++, unset QGraphicsItem::ItemHasNoContents flag in your custom class and implement paint method. More details: http://qt-project.org/doc/qt-4.8/qdeclarativeitem.html