1 | initial version |
Firstly you need to use boundingRect() to generate Rect, which will give you coordination. (and looks like you did.)
Then you can use sorted() with a key function to generate key value using (x, y), something like key = y * 3000 + x.
This should do the work.