To avoid such struggles in the future, the Yongzheng Emperor designed a system by which the living emperor would choose his successor in advance and on merit, but would keep his choice secret until his deathbed.
When the Tongzhi Emperor died heirless in 1874, his mother Empress Dowager Cixi was the one who selected the next emperor.