Issue is here:
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(changeVoltage()),Qt::DirectConnection );
I assume timer is also a class member, otherwise code won't compile. In the code above you replace class member with stack variable. Fix is:
timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(changeVoltage()),Qt::DirectConnection );