4. Given that $a, b$ are positive real numbers, let
$$
\begin{aligned}
P & =\sqrt{\frac{a^{2}+b^{2}}{2}}-\frac{a+b}{2}, Q=\frac{a+b}{2}-\sqrt{a b}, \\
R & =\sqrt{a b}-\frac{2 a b}{a+b} .
\end{aligned}
$$

Then the correct judgment is ( ).
(A) $P \geqslant Q \geqslant R$
(B) $Q \geqslant P \geqslant R$
(C) $Q \geqslant R \geqslant P$
(D) The size relationship of $P, Q, R$ cannot be determined
4. B.

Notice,
$$
\begin{array}{l}
P \leqslant Q \Leftrightarrow \sqrt{\frac{a^{2}+b^{2}}{2}}+\sqrt{a b} \leqslant a+b \\
\Leftrightarrow 2 \sqrt{\frac{a^{2}+b^{2}}{2}} \cdot a b \leqslant \frac{a^{2}+b^{2}}{2}+a b .
\end{array}
$$

Thus, the inequality holds.
$$
\begin{array}{l} 
P \geqslant R \Leftrightarrow \sqrt{\frac{a^{2}+b^{2}}{2}}-\sqrt{a b} \geqslant \frac{a+b}{2}-\frac{2 a b}{a+b} \\
\Leftrightarrow \frac{a^{2}+b^{2}}{2}+3 a b-\sqrt{2 a b\left(a^{2}+b^{2}\right)} \\
\geqslant \frac{(a+b)^{2}}{4}+\frac{4 a^{2} b^{2}}{(a+b)^{2}} \\
\Leftrightarrow \frac{(a+b)^{2}}{4}+\frac{2 a b\left(a^{2}+b^{2}\right)}{(a+b)^{2}} \geqslant \sqrt{2 a b\left(a^{2}+b^{2}\right)} .
\end{array}
$$

Thus, the inequality holds.
In summary, $Q \geqslant P \geqslant R$.