Not generally good form to reply to oneself, but it seems OpenGL isn't scaled on hiDpi screens, according to this
So calling QApplication::desktop()->devicePixelRatio() gives me a pixel ratio of 2, which means I guess I just set 'trect' in the code to have w and h scaled by 2.
Interestingly, the screen is not scaled by 2, it's a 3200x1800 display on a native resolution of 5120x2880. The ultra-high DPI is just too much, but I want more than the standard half-resolution.