NIST thinks that 2048 bit RSA will be secure until 2030. Presumably their analysis does not include a quantum computer, because if it did they wouldn't recommend 3072 bit RSA for security beyond 2030. Their analysis is indexed against DES (so cracking 2048 bit RSA using the best known methods would be equivalent to cracking a hypothetical 112-bit DES).
It's possible that you're right that a quantum computer won't exist in 2040 that will break 2048 bit RSA, but that doesn't mean it won't be broken anyway by then.