问题标签 [qvariantanimation]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - QPainters 同步背后的机制
语境
我有一个自定义小部件,它应该制作点移动的动画,以制作一种加载小部件。为了实现这个目标,我开始使用 QPainter 和 QVariantAnimation 对象,这似乎是完成这项工作的不错工具。问题是我认为我在绘图时初始化的 QPainter 相互冲突。
技术
为了实现这一点,我初始化了多个 QVariantAnimation,它表示 .valueChanged() 我连接到一个函数 update(),它应该启动 painEvent(),例如文档中所写
绘制事件是重新绘制全部或部分小部件的请求。它可能由于以下原因之一发生:调用了 repaint() 或 update(),小部件被遮挡并且现在已被发现,或许多其他原因。
由于我在不同的时间启动不同的动画,我认为 update() 被调用了很多次,从而干扰了另一个已经在工作的 QPainter。但是,正如我在文档中所读到的,
当 update() 被多次调用或窗口系统发送多个绘制事件时,Qt 将这些事件合并为一个具有更大区域的事件。
但它没有指定 QPainter 具有相同的区域,这就是我认为它崩溃的原因。它记录以下消息:
最小的工作示例
结果
我知道现在这段代码不起作用,因为我无法检索更新了哪个点的动画,但我相信这里的主要问题是画家之间的干扰。因此,谁能告诉我为什么会发生这种情况并指出一个潜在的解决方案?另外,为了知道更新的点并选择了好的位置,我真的不确定如何做到这一点。
python - TypeError: PyQt4.QtCore.QVariantAnimation 表示C++抽象类,不能实例化
我有这个 PyQt5 片段,我正在尝试将其转换为 PyQt4。PyQt5 版本运行良好,但是当我尝试转换为 PyQt4 时,出现此错误。我删除了QtWidgets
,但我仍然收到此错误。我也尝试仅实例化self.animation = QtCore.QVariantAnimation()
但仍然得到相同的错误。
工作 PyQt5 版本
坏掉的 PyQt4 版本
有谁知道如何解决这一问题?
python - QVariantAnimation of opacity : 项目出现在动画的最后
这是一个示例,其中图形项目出现在动画的末尾,而不是像它应该的那样逐渐出现。
而不是white2.png,请放置任何图像文件。
知道为什么它会这样工作吗?
总而言之,我也可以使用 QPropertyAnimation ,但对于可能相同的结果,它的工作量更大。
qt - How to create an animation toggle in Qt?
The requirement is When I click the button, the size of the detailText
object will be enlarged/shrunken (BOTH CASES) as an animation.
This is my code:
With this code, there are two problems:
When the
detailText
is invisible, and I click the button: the whole window is suddenly extended, and then there is animation for thedetailText
. I need the animation of thedetailText
makes the size of window larger accordingly. Or in another word, the enlargement of the whole window and the animation ofdetailText
are synchronized.The animation happens only one way: when
detailText
is invisible, I click the button,detailText
will be shown and there is animation. But whendetailText
is visible, I click the button, thedetailText
is hidden, but no animation, the size of window is suddenly shrunken.
How should I correct my code?
My *.ui file:
python - 如何制作恒定流畅的动画?
所以我想制作一个动画作为 Waze 应用程序中的箭头,我希望它平滑且恒定地移动。我不知道如何在 QtGraphicsView 中做到这一点。我的对象(箭头)移动了一个 QVariantAnimation,它从当前位置插入到下一个位置。结束它稍微停止。我不想要这个功能(停止),我想要我的动画连续流畅地运行。有谁知道怎么做?
这是一个最小的可重现示例:
python - QVariantAnimation 循环动画 CPU 使用率
我正在尝试在循环中为帧的背景设置动画,因此它从 color1 变为 color2 再到 color1 等。
这是我到目前为止正在工作的东西,但它占用了我认为不应该占用的 CPU 的 2-3%:
我相信应该有一种更优雅的方式不会导致这种 CPU 使用率,但我无法弄清楚。问题是我有一个相当高端的 CPU,如果它在这个 CPU 上运行 2-3%,它会在我们将运行这个程序的一些较慢的 CPU 上导致更多。如果我不做动画,它是 0%。
python - 将动态小部件对象传递给 QVariantAnimation valueChanged 信号处理程序
我正在尝试制作无效的动画工具。我有一个按钮,当按下该按钮时,会将字段的背景颜色从红色设置为“正常”字段颜色。这很好用,但现在我想传入任意PyQt 小部件对象(可以是QLineEdit
、QComboBox
等)。这是我的动画处理程序的样子:
目前它要求field
在调用函数更改背景之前已经命名对象。我希望能够widget
通过传入参数来动态传入 a 并动态设置样式表,如下所示:
当我尝试这样做时,可以传递小部件,但是从WARNING_COLOR
到的恒定颜色变化NORMAL_COLOR
不再起作用。我也不想把它放到一个类中,因为它必须是即时的。我的目标是能够调用一个函数来从任何地方开始动画,而不必按下按钮。期望的目标是这样的:
最小的工作示例