<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[I have sample show video app, can you guys check for me pls ?]]></title><description><![CDATA[<p dir="auto">QML:<br />
VideoItem {<br />
id: videoItem<br />
anchors.fill: parent</p>
<pre><code>            Connections {
                target: videoController
                function onFrameReady(frame) {
                    if (window.isPlaying &amp;&amp; videoItem) {
                        try {
                            videoItem.updateFrame(frame)
                            window.frameCount++
                            debugText.text = "Frames: " + window.frameCount
                        } catch (e) {
                            console.error("Error updating frame:", e)
                        }
                    }
                }
                
                function onErrorOccurred(error) {
                    window.errorMessage = error
                    if (error) {
                        loadingIndicator.visible = true
                    } else {
                        loadingIndicator.visible = false
                    }
                }
                
                function onConnectionStatusChanged(status) {
                    loadingIndicator.visible = !status
                }
            }
        }
</code></pre>
<p dir="auto">video_item.py:<br />
from PySide6.QtQuick import QQuickPaintedItem<br />
from PySide6.QtGui import QImage, QPainter<br />
from PySide6.QtCore import Qt, Slot</p>
<p dir="auto">class VideoItem(QQuickPaintedItem):<br />
def <strong>init</strong>(self, parent=None):<br />
super().<strong>init</strong>(parent)<br />
self._frame = None<br />
self.setRenderTarget(QQuickPaintedItem.FramebufferObject)<br />
self.setAntialiasing(True)</p>
<pre><code>def paint(self, painter: QPainter):
    if self._frame is None:
        return
        
    # Scale image to fit while maintaining aspect ratio
    rect = self.boundingRect()
    scaled_image = self._frame.scaled(
        rect.width(), 
        rect.height(),
        Qt.KeepAspectRatio,
        Qt.SmoothTransformation
    )
    
    # Center the image
    x = (rect.width() - scaled_image.width()) / 2
    y = (rect.height() - scaled_image.height()) / 2
    painter.drawImage(x, y, scaled_image)

@Slot(QImage)
def updateFrame(self, frame):
    if frame is None:
        return
    self._frame = frame
    self.update()

@Slot()
def releaseResources(self):
    self._frame = None
    self.update() 
</code></pre>
<p dir="auto">Main py:<br />
qmlRegisterType(VideoItem, "CustomVideo", 1, 0, "VideoItem")</p>
<pre><code># Khởi tạo controller
controller = VideoController()

# Thiết lập QML
engine.rootContext().setContextProperty("videoController", controller)
engine.load(QUrl.fromLocalFile("customvideo.qml"))
</code></pre>
]]></description><link>https://forum.qt.io/topic/160653/i-have-sample-show-video-app-can-you-guys-check-for-me-pls</link><generator>RSS for Node</generator><lastBuildDate>Fri, 13 Mar 2026 01:46:42 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/160653.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Jan 2025 04:10:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to I have sample show video app, can you guys check for me pls ? on Mon, 20 Jan 2025 19:51:30 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">What exactly are you expecting from people here ?</p>
<p dir="auto">On a side note, please using coding tags (using for example de <code>&lt;/&gt;</code> button) to make your code readable.</p>
]]></description><link>https://forum.qt.io/post/819188</link><guid isPermaLink="true">https://forum.qt.io/post/819188</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 20 Jan 2025 19:51:30 GMT</pubDate></item></channel></rss>