Skip to Content
Game Programming Using Qt Beginner's Guide
book

Game Programming Using Qt Beginner's Guide

by Witold Wysota, Lorenz Haas
January 2016
Beginner
512 pages
12h 35m
English
Packt Publishing
Content preview from Game Programming Using Qt Beginner's Guide

Time for action – creating items with different origins

Let's have a closer look at these three items defined by the following code snippet:

QGraphicsRectItem *itemA = QGraphicsRectItem(-10, -10, 20, 20);
QGraphicsRectItem *itemB = QGraphicsRectItem(0, 0, 20, 20);
QGraphicsRectItem *itemC = QGraphicsRectItem(10, 10, 20, 20);

What just happened?

All three items are rectangles with a side length of 20 pixels. The difference between them is the position of their coordinate origin points. itemA has its origin in the center of the rectangle, itemB has its origin in the top-left corner of the rectangle, and itemC has its origin outside the drawn rectangle. In the following diagram, you see the origin points marked as red dots.

So what's the deal with ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Game Programming using Qt 5 Beginner's Guide - Second Edition

Game Programming using Qt 5 Beginner's Guide - Second Edition

Pavel Strakhov, Witold Wysota, Lorenz Haas
Programming with Qt, 2nd Edition

Programming with Qt, 2nd Edition

Matthias Kalle Dalheimer

Publisher Resources

ISBN: 9781782168874Supplemental Content