Pulling a Meiji successfuly.
I doubt having Emperor Meiji in charge of the Qing Empire would end well.
On a more serious note, Meiji as a byword for modernisation is a pet peeve of mine simply because the conditions for the Meiji Restoration (a decentralised, culturally homogenous, highly urbanised and educated domain with a long history of trade and importing cultural and technological innovations from the west (Dutch Studies) in amounts allowing it to not lag too far behind the west while not destabilising it entirely, large enough of a market for the western powers to be interested without being self-sufficient enough to eschew trade with Europe with leadership reasonable/humble/sane enough to accept the changing tides of geopolitics and thus avoid being attacked for trade rights, and able to transition from one power structure to another with relatively little bloodshed is very specific to late Tokugawa Japan and would not be a proper model for the ethnic-minority-ruled, Europe-demeaning, self-sufficient-and-thus-only-opium-satisfies-the-trade-imbalance, keeps-having-massive-rebellions Qing empire).
But, back to the OP, the Qing actually being willing to trade with the Western Powers without being held at gun(boat) point would go a long way to avoiding the Opium Wars, since the primary motivation in selling the titular opium was to avoid further drainage of silver from Europe into China and to gain more trade rights with the world's largest market. Not everyone in Britain was onboard with the Opium Wars either, Gladstone being a notable example, so they weren't guaranteed to happen if trade with China isn't restricted in the first place.
Then there's the issue of overpopulation (the Chinese population doubled from 1766 to 1833), natural disasters (can't really stop those with any PoDs) and anti-Manchu sentiment in general, but the Opium Wars have a more obvious solution than those two and destroyed the illusion of Chinese military might, which contributed to the Century of Humiliation in a significant way with all the later wars the Qing had to fight. Granted, they'd still have major issues and the Qing court was corrupt beyond belief but they'd have a better shot at surviving further into the 20th century.