QRect rect(0, 0, 100, 50); QRect moved_rect = rect.translated(5, 10);
QRect rect(0, 0, 100, 50); QPoint offset(10, 20); QRect moved_rect = rect.translated(offset);This code is similar to the first example, but instead of passing the offset as separate parameters, it is passed as a QPoint object. Package library: Qt 5 Core Library.