如何获取Qt小部件的位置?
这是代码如何获取Qt小部件的位置?,qt,animation,Qt,Animation,这是代码 QPropertyAnimation *animation3 = new QPropertyAnimation (ui->modifyButton, "geometry"); animation3->setDuration(1000); animation3->setStartValue(QRect(20, 120, 141, 20)); animation3->setStopValue(QRect(20, 70, 141, 20)); animation3-
QPropertyAnimation *animation3 = new QPropertyAnimation (ui->modifyButton, "geometry");
animation3->setDuration(1000);
animation3->setStartValue(QRect(20, 120, 141, 20));
animation3->setStopValue(QRect(20, 70, 141, 20));
animation3->start();
我需要应用程序自动确定modifyButton的“Y”坐标,因为它不是固定的并且正在更改。那么我怎么能做这样的事情呢
int y = get_y_coordinate_somehow();
animation3->setStartValue(QRect(20, y, 141, 20));start();
使用pos()
方法
int y = pos().y();