- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
问题是当我调用QPropertyAnimation.start()
时,什么也没发生。
颜色是我要设置动画的属性,按钮是类。
class Button(QPushButton):
def __init__(self,text="",parent=None):
super(Button,self).__init__(text,parent)
# ...
self.innercolor = QColor(200,0,20)
def setcolor(self,value): self.innercolor = value
def getcolor(self): return self.innercolor
color = Property(QColor,getcolor,setcolor)
def paintEvent(self, event):
p = QPainter(self)
p.fillRect(self.rect(),self.color)
# ...
p.end()
def animated(self,value): print "animating"; self.update()
def enterEvent(self, event):
ani = QPropertyAnimation(self,"color")
ani.setStartValue(self.color)
ani.setEndValue(QColor(0,0,10))
ani.setDuration(2000)
ani.valueChanged.connect(self.animated)
ani.start()
print ani.state()
return QPushButton.enterEvent(self, event)
我很困惑,因为"animating"
永远不会打印出来,但是 ani.state()
说动画正在运行。
我并不是要求调试我的代码或任何东西,但我认为我一定缺少一些东西,无论是在我的代码中还是在我对 QPropertyAnimation
的使用的理解中。 .
我在谷歌上搜索了答案,但没有任何结果,无论如何也没有与我相关的内容。我发现的最接近的是 another SO question ,但我仍然无法将其转化为自己的答案。我还看到了一些关于自定义插值器的内容,我是否需要制作自定义插值器,如果需要,我该怎么做。
最佳答案
很酷的代码。它几乎可以工作,但是动画不会在 EnterEvent 之后持续存在(尽管我不完全理解其机制。)如果您更改
ani = QPropertyAnimation(self,"color")
到
self.ani = QPropertyAnimation(self, "color")
# etc
然后就可以了。
关于python - PySide QPropertyAnimation 未启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18291726/
我正在尝试在 Qt 桌面应用程序中测试动画。我刚刚从帮助中复制了示例。单击按钮后,新按钮仅出现在左上角,没有动画(甚至结束位置也是错误的)。我错过了什么吗? Qt 5.0.1、Linux Mint 6
我正在设置一个新的桌面小部件,以使我的工作生活更轻松,并使用 QPropertyAnimation 使其变得漂亮。淡入淡出应用程序似乎不想起作用,并且以典型的编码方式,它使我的进度陷入停滞。 我正在个
我想让许多彩色点在背景上不断移动。 (下面的代码说明):PolkaDot 小部件是用随机颜色、大小、位置和持续时间构建的。 QPropertyAnimation 在屏幕上从左到右移动小部件,并在动画结
我的动画在这个 QPushButton 上没有按照我预期的方式工作。 这是我的 mainwindow.cpp,因为您在这里看不到任何特别奇怪的地方。在运行时,该按钮如人们所期望的那样出现。我没有任何特
我正在尝试使用多个 QPropertyAnimation 向上移动一个小部件,然后向右移动。 代码如下: QPropertyAnimation* animationUp; QPropertyAnima
这是我的代码: void Widget::update() { if (a==1) { QPushButton button("Animated Button");
我正在尝试使用 Qt 的动画框架。我正在使用 Qt 网站上的一些示例代码,但它无法正常工作,错误:setGeometryDp: 无法在 QWidgetWindow/'QPushButtonClassW
下面的代码没有按预期为按钮设置动画。但如果按钮是独立的并且在它是子部件时停止工作,它会起作用。我在这里做错了什么? 我正在 Ubuntu 上尝试这个。 class TestWindow(QtGui.Q
我正在学习 Qt,认为动画按钮很重要。我正在尝试创建我的自定义 QPushButton 类,它重新实现鼠标进入和离开事件并使用 qt 动画框架。 QPropertyAnimation QPropert
Qt 4.6+ 中的新动画框架基于具有“void setUpdateInterval(int interval)”公共(public)函数的 QTimeLine。基于 QTimeLine,QGraph
我有以下问题:我想使用 QPropertyAnimation 调整窗口大小,以便看起来不错,但是在调整大小时窗口也会立即移动,虽然我不想这样做,但我只想调整窗口大小和不改变其位置值。 所以,这是我的代
我试图在按下按钮时生成动画,但在 self.frame2 返回到大小 0 后它不起作用: 这是一个例子: 帧返回0后,动画不再执行: from PyQt5.QtWidgets import QMain
尝试使用 PyQt5 并使用 QPropertyAnimation 对一条从无到有 (0,0) 到 (200, 200) 的线进行动画处理。我已经阅读了大量有关 Qt 的文档并尝试了几个示例,但我就是
根据以下代码片段,我对QPropertyAnimation 和QParallelAnimationGroup 有疑问: // Create the opacity animation QPropert
我面临一个非常严重的情况。通过写这个问题,我希望真正的专业人士对我将要描述的问题发表意见。我在 https://bugreports.qt.io/ 中报告了一个错误: I have created Q
问题是当我调用QPropertyAnimation.start()时,什么也没发生。 颜色是我要设置动画的属性,按钮是类。 class Button(QPushButton): def __i
请参阅下面的代码。我有一个启动动画的按钮。问题是我只在按下第二个按钮后才看到动画。但是当动画开始时,我注意到它实际上从第一次按下按钮开始就开始了,因为它从一个时刻开始 = [第 1 次和第 2 次按钮
我创建了一个 QRect 对象 QRect ellipse(10.0 , 10.0 , 10.0 , 10.0); QPainter painter(this); painter.setBrush(Q
1。简介 我在 Windows 10 上使用 Python 3.7 并使用 PyQt5 作为 GUI。在我的应用程序中,我得到了一个 QScrollArea()里面有一排按钮。单击时,按钮必须移出该区
我想在 2 秒的时间内逐渐降低 QPushButton 的不透明度以完全透明。为此,我使用了 QPropertyAnimation 类并使用按钮的属性“windowOpacity”来实现效果。但这仅适
我是一名优秀的程序员,十分优秀!