Managed to make it work.
It's frustrating and embarassing
, the solution was what i was trying to do, but in a way that actually works. I was trying to change the "_HandledWindow" by its size, height, width and view proprierties, passing coordinates, but what i was actually supposed to do is
_HandledWindow.view.size = (x,y)
Did not even need this in the end, just needed to use the solution below.
To make it work, every time that the window is resized, you must pass a new viewport to the sfml window so it knows it's new dimensions. This also fix the "growing upwards instead of downwards" problem.
# Main Frame
class MainFrame(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
#The reason this is here is to avoid instanciating too many objects
self.view = sf.View()
def resizeEvent(self,resizeEvent):
print("resized")
#The line below makes the visible area expand/retract instead of zooming in/out
self.view.reset(sf.Rectangle((0,0),(sfmlwidgetpointer.width(),sfmlwidget.height())))
self.view.viewport = sf.Rectangle((0,0),(1,1))
sfmlwidget._HandledWindow.view = self.view
mainframe = MainFrame()
...
sfmlwidget = SFMLCanvas(mainframe, position, size)
...
The problem was the programmer today, who could've known? Nobody.