Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to fit widget with set size properly for game?
QtWS25 Last Chance

How to fit widget with set size properly for game?

Scheduled Pinned Locked Moved Unsolved General and Desktop
gameqgraphicsviewqwidget
2 Posts 2 Posters 270 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    misscoffee
    wrote on 24 May 2023, 04:58 last edited by misscoffee
    #1

    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

    J 1 Reply Last reply 24 May 2023, 05:39
    0
    • M misscoffee
      24 May 2023, 04:58

      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

      J Offline
      J Offline
      JonB
      wrote on 24 May 2023, 05:39 last edited by
      #2

      @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.

      1 Reply Last reply
      4

      1/2

      24 May 2023, 04:58

      • Login

      • Login or register to search.
      1 out of 2
      • First post
        1/2
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved