【问题标题】:Animate the resizing of a QListView动画 QListView 的大小调整
【发布时间】:2014-09-10 12:14:25
【问题描述】:

我有一个 QListView,我可以通过调用 updateGeometry 来适应内容。现在我想为它制作动画。我不能使用 resizeEvent,因为它是在 小部件被调整大小之后调用的。开始这个动画的正确位置是什么,因此内部调用了哪些成员?

【问题讨论】:

    标签: c++ qt qt5 qpropertyanimation


    【解决方案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。我认为不止这些。希望对您有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-07
      • 1970-01-01
      • 1970-01-01
      • 2018-04-18
      • 2014-07-29
      相关资源
      最近更新 更多