2014-09-10 213 views
0

我有一個QListView,我可以適應內容通過調用updateGeometry。現在我想爲它製作動畫。我無法使用resizeEvent,因爲它在之後調用小部件已調整大小。什麼是開始這個​​動畫的合適位置,ergo哪些成員在內部被調用?動畫調整大小的QListView

回答

1

那麼,你應該離開QListView,而不是集中在它的模型上。比方說,你有這樣的:

QListView *myListView; 

在這種情況下,你應該注意它的模型,這意味着:

QAbstractItemModel *myListModel(myListView->model()); 

您可以連接一些插槽(取決於當你要開始上動畫,之前或數據被通過的意見獲取),可能像後:

connect(myListModel, &QAbstractItemModel::rowsAboutToBeInserted, myHandlingObject, &MyHandlingObjectClass::myHandlingSlot); 

或:

connect(myListModel, &QAbstractItemModel::rowsInserted, myHandlingObject, &MyHandlingObjectClass::myHandlingSlot); 

在MyHandlingObjectClass :: myHandlingSlot()槽內,您最終會啓動一個QPropertyAnimation。我認爲這不僅僅是這個。希望能幫助到你!