main.qml
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Window {
id: window
width: 500
height: 400
visible: true
title: qsTr("主窗体")
}
Image {
id: image
x: 37
y: 56
width: 100
height: 100
anchors.fill : parent
asynchronous:false
cache:false
source: "image://myprovider/test.png"+Math.random()
fillMode: Image.PreserveAspectFit
}
}
Timer {
id: timer_button;
interval: 10;//设置定时器定时时间为500ms,默认1000ms
repeat: true //是否重复定时,默认为false
running: true //是否开启定时,默认是false,当为true的时候,进入此界面就开始定时
triggeredOnStart: true // 是否开启定时就触发onTriggered,一些特殊用户可以用来设置初始值。
onTriggered: {
//定时触发槽,定时完成一次就进入一次
image.source = "image://myprovider/"+ Math.random()
}
//restart ,start,stop,定时器的调用方式,顾名思义
}
}
main.py
import os
from pathlib import Path
import sys
from PySide2.QtCore import *
from PySide2