You do not set the new icon. I think it should be like:
buttons[0]->setIcon(buttons[0]->icon().swap(buttons[1]->icon()));
However this will change only the first button's icon.
I would write it in more simple way, which is easier to read and understand:
QIcon tmp = buttons[0]->icon();
buttons[0]->setIcon(buttons[1]->icon());
buttons[1]->setIcon(tmp);