我有QListWidget,我需要从一个点移动到另一个,但它必须慢,像动画。你能帮我解决这个问题吗?Qt C++缓慢移动QListWidget
回答
您需要为此使用Qt Animation framework。有很多样品可供使用,所以你应该阅读它。
你正在尝试做可以QPropertyAnimation类来完成,通过动画的QListWidget
geometry属性:
QPropertyAnimation animation(&lstWidget, "geometry"); //animate geometry property
animation.setDuration(5000); // 5 seconds
animation.setStartValue(QRect(50, 50, 100, 100)); // start value for geometry property
animation.setEndValue(QRect(300, 300, 100, 100)); // end value for geometry property
animation.start();
这会从(50,50)部件移动到(300,300)。您可以通过从lstWidget
读取geometry
属性来设置起始值,以开始从当前位置移动等。
我试过了,但它不是动画,只是跳到新的位置。当按下按钮时,我需要运行这些代码行。所有这些都是使用Qt Designer完成的。 – Alen 2013-02-15 16:53:45
@Alen确保在退出该功能时不会删除动画对象。尝试在堆上分配动画('QPropertyAnimation * animation = new QPropertyAn ...')并调用'animation-> start()',或者将'animation'移动到您的类成员上,因为您将一次又一次地使用它。 – 2013-02-15 17:04:15
Hvala @Nemanja :) – Alen 2013-02-15 17:10:56
- 1. div移动非常缓慢
- 2. Qt - 移动无框窗口(缓慢重绘?)
- 3. Python Qt QListWidget双击
- 4. Qt - 缓慢的GUI - 线程
- 5. C程序启动缓慢
- 6. 缓慢地移动一个jQuery滑块
- 7. 标签缓慢向后移动
- 8. 可可触摸 - 缓慢移动CGPointMake
- 9. QListWidget自动移动到列表结尾
- 10. C++ - QListWidget
- 11. Qt QListWidget性能问题
- 12. Python Qt QListWidget项目拖放
- 13. Qt QListWidget addItem内存泄漏
- 14. SQLalchemy缓慢与红移
- 15. C#缓慢搜索
- 16. 在QListWidget中上下移动项目?
- 17. Qt Quick非常缓慢的绘画
- 18. 使用Qt C++ QWebView使GUI运行缓慢。
- 19. qt-如何在慢动作中移动图片
- 20. 滚动UITableView缓慢
- 21. UIImageView动画缓慢
- 22. TableView滚动缓慢
- 23. Hazelcast缓慢启动
- 24. 在pyinstaller中删除对matplotlib和qt的依赖(缓慢启动)
- 25. 移动语义慢然后复制C++
- 26. 在触摸移动图像拖动得到缓慢
- 27. jquery移动列表查看缓慢和不平滑滚动
- 28. 轮形滚动视图缓慢移动视频
- 29. 如何在用户滚动页面时缓慢移动标题?
- 30. WP7 Bing地图控件在缓慢拖动时不可移动
您是否已阅读过Qt Animation框架? – divanov 2013-02-15 16:40:41