Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to scale or stretch RenderWindow to fit into a Qt QWidget window?  (Read 3751 times)

0 Members and 1 Guest are viewing this topic.

ccleung6

  • Newbie
  • *
  • Posts: 22
    • View Profile
Hi,

I follow the SFML tutorial to subclass a QWidget from SFML RenderWindow.
But I have no idea how to scale the render window when the QWidget window resizes.

Assume the render window is 640 * 480, the QWidget window is resized to 800 * 600,
is that I need to resize render window to 800*600 and scale everything by a scaling factor for drawing?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10822
    • View Profile
    • development blog
    • Email
Re: How to scale or stretch RenderWindow to fit into a Qt QWidget window?
« Reply #1 on: September 29, 2012, 05:01:03 pm »
I have no idea how SFML and Qt are connected but to resize a sf::RenderWindow you simply create a new one, i.e. call the create(...) function on the render window object.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: How to scale or stretch RenderWindow to fit into a Qt QWidget window?
« Reply #2 on: September 29, 2012, 06:12:50 pm »
You should have nothing to do. What happens currently?
Laurent Gomila - SFML developer

ccleung6

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: How to scale or stretch RenderWindow to fit into a Qt QWidget window?
« Reply #3 on: September 30, 2012, 04:19:14 am »
You should have nothing to do. What happens currently?

The problem is when the Qt window resizes, the inner sf::RenderWindow remains the same size, it won't scale or stretch all all.
But I want it to scale/stretch to fit the container window size.

Any idea to do that?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: How to scale or stretch RenderWindow to fit into a Qt QWidget window?
« Reply #4 on: September 30, 2012, 09:37:03 am »
It should work automatically. But if it doesn't, try to call window.setSize(...).
Laurent Gomila - SFML developer

 

anything