Unsolved If override QGraphicsView::resizeEvent, should I call the base function as well?
-
I have derived class that inherits from QGraphicsView, I have need to override QGraphicsView::resizeEvent(QResizeEvent*), I am just changing the properties of some elements when the QGraphicsView size changes. I noticed that QGraphicsView itself apparently re-declares resizeEvent as well (according to the refactoring feature of Qt Creator). My question is simple, should I also call the base QGraphicsView::resizeEvent as well, or does it magically do it's resizeEvent thing regardless if I have made override function? If I should call the base function as well, should I do it before or after I do my custom stuff?
Thanks.
-
@snorkelbuckle said in If override QGraphicsView::resizeEvent, should I call the base function as well?:
or does it magically do it's resizeEvent thing regardless if I have made override function?
How should this work when you don't call the base function? C++ Basics.
See for example here: https://www.programiz.com/cpp-programming/multilevel-multiple-inheritance -
Thanks for that, but I'm not clear on what you are asking. I do know the basics, thank you. I guess I should be more clear, I'm asking what exactly does the re implemented base function of resizeEvent in QGraphicsView actually do? I need to know this to determine if I should call the re implemented base function in my override function. Technically it is not required to call the base function unless there is something important it needs to do that is documented. And therein lies the root of the problem, there is no documentation about what the re-implementation does in QGraphicsView. All that is documented is that it is "re implemented". So there needs to be an explanation to the developer in case developer re-implements in his derived class which I have done.
As to your question, I don't know how it should work, that is why I'm asking, will QGraphicsView work correctly if I call the base function or should I not call the base function, and if I call the base function, in what order should I call it.
-
You really should call the Qt base class implementations in all cases - https://code.woboq.org/qt5/qtbase/src/widgets/graphicsview/qgraphicsview.cpp.html#_ZN13QGraphicsView11resizeEventEP12QResizeEvent