Goals from Bernardo Silva, Ronaldo and Joao Cancelo helped the Portuguese pip Hungary, who found the net through Barnabas Varga twice.