qt列表平滑移动效果,半拉子工程,但是稍微改动可以用!
QTableWidget *table = new QTableWidget(this);
table->setRowCount(5);
table->setColumnCount(15);
table->setWindowTitle(“QTableWidget & Item”);
table->resize(400, 200); //设置表格
QList nameList;
nameList << “亚瑟” << “安琪拉” << “妲己” << “东皇太一” << “孙膑” << “亚瑟” << “安琪拉” << “妲己” << “东皇太一” << “孙膑”<< “亚瑟” << “安琪拉” << “妲己” << “东皇太一” << “孙膑” << “亚瑟” << “安琪拉” << “妲己” << “东皇太一” << “孙膑”<< “亚瑟” << “安琪拉” << “妲己” << “东皇太一” << “孙膑” << “亚瑟” << “安琪拉” << “妲己” << “东皇太一” << “孙膑”;
QStringList sexList;
sexList << “男” << “女” << “女” << “男” << “中立”<< “男” << “女” << “女” << “男” << “中立” << “男” << “女” << “女” << “男” << “中立”<< “男” << “女” << “女” << “男” << “中立” << “男” << “女” << “女” << “男” << “中立”<< “男” << “女” << “女” << “男” << “中立”;
for (int i = 0; i < 15; i++)
{
int col = 0;
table->setItem(i, col++, new QTableWidgetItem(nameList[i]));
table->setItem(i, col++, new QTableWidgetItem(sexList.at(i)));
//int 转 QString QString::number(int)
table->setItem(i, col++, new QTableWidgetItem(QString::number(i + 18)));
}
QTableWidget *table2 = new QTableWidget(this);
table2->setRowCount(5);
table2->setColumnCount(15);
table2->setWindowTitle("QTableWidget & Item");
table2->resize(400, 200); //设置表格
for (int i = 0; i < 15; i++)
{
int col = 0;
table2->setItem(i, col++, new QTableWidgetItem(nameList[i]));
table2->setItem(i, col++, new QTableWidgetItem(sexList.at(i)));
//int 转 QString QString::number(int)
table2->setItem(i, col++, new QTableWidgetItem(QString::number(i + 18)));
}
/* 声明动画类,并将控制对象 this (this一定是继承自QObject的窗口部件) 以及属性名 "geometry" 传入构造函数 */
QPropertyAnimation* animation = new QPropertyAnimation(table, "geometry");
/* 设置动画持续时长为 2 秒钟 */
animation->setDuration(3000);
/* 设置动画的起始状态 起始点 (1,2) 起始大小 (3,4) */
animation->setStartValue(QRect(1,0, 400, 200));
/* 设置动画的结束状态 结束点 (100,200) 结束大小 (300,400) */
animation->setEndValue(QRect(1, -200, 400, 200));
/* 设置动画效果 */
animation->setEasingCurve(QEasingCurve::OutInExpo);