我有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. C程序启动缓慢
- 4. 可可触摸 - 缓慢移动CGPointMake
- 5. 标签缓慢向后移动
- 6. QListWidget自动移动到列表结尾
- 7. Qt QListWidget addItem内存泄漏
- 8. Qt QListWidget性能问题
- 9. C#缓慢搜索
- 10. Qt Quick非常缓慢的绘画
- 11. qt-如何在慢动作中移动图片
- 12. 使用Qt C++ QWebView使GUI运行缓慢。
- 13. UIImageView动画缓慢
- 14. TableView滚动缓慢
- 15. Hazelcast缓慢启动
- 16. 滚动UITableView缓慢
- 17. 在pyinstaller中删除对matplotlib和qt的依赖(缓慢启动)
- 18. 移动语义慢然后复制C++
- 19. WP7 Bing地图控件在缓慢拖动时不可移动
- 20. Qt中的QListWidget这样的博客
- 21. SQLite C++ API交易缓慢
- 22. Listview缓慢刷新c#
- 23. MongoDB的C#GeoNEar缓慢
- 24. PyQt4的:移动从一个QListWidget项目的方式
- 25. 移动Qt目录
- 26. CSS动画缓慢而慢 - CPU性能?
- 27. Qt - 在MainWindow上显示由QListWidget选择的动画GIF
- 28. RecyclerView滚动非常缓慢和迟缓
- 29. GridView非常缓慢滚动
- 30. IronPython启动非常缓慢
您是否已阅读过Qt Animation框架? – divanov 2013-02-15 16:40:41