Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何获取Qt小部件的位置?_Qt_Animation - Fatal编程技术网

如何获取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();