我有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