How to fit widget with set size properly for game?
-
I have class inherited by QGraphicsView(but I can change it if you give right solution) and global constants which set it`s width and size like WIDTH and HEIGHT. I just want to have QGraphicsView and QGraphicsScene on full screen with the correspondence of the sizes that I set with the position on the screen. So that the origin of the coordinates is exactly in the upper left corner and if some item has position (WIDTH/2, HEIGHT/2) it's actually located on the CENTER of the screen. So that the exact boundaries of the screen was limited by 0, HEIGHT by Y axis and by 0, WIDTH by X axis
-
@misscoffee
So just set the size of the view and/or scene to the full size of the screen/desktop. You can also use void QWidget::showFullScreen() (see the warnings there).Be aware that widgets/windows have borders, and a title bar unless you specify otherwise, so the view/scene may not occupy every pixel of the screen, unless you take action, if that matters to you. IIRC, graphics scene/view places coordinate (0,0) in the center with x,y increasing right/up. You can use
setSceneRect()
to alter this.