[SOLVED]Reimplementing a virtual function, but with different parameters
-
EDIT: So, apparently trying for hours to solve a problem and finally posting an inquiry on a message board magically gives me the power to work around said problem. To whom it may concern, I now used static variables for my coordinates and everything works just dandy.
Hey everybody,
I have recently been getting back to c++ after a while and have a probably pretty simple problem with my most recent project.
I basically have two windows on the screen (courtesy of Qt of course). One of them is for settings, the other for displaying 3D graphics. The settings window (inherits from QMainWindow) has (among others) a "load config" button which lets me, well, load some numbers from a file. It's all working fine.
However, if I want to use those numbers as coordinates in the other "3D" window (inherits from QGLWidget), I have to reimplement (of course) the paintGL() function. paintGL(), however, takes zero arguments. I have successfully reimplemented initializeGL() and resizeGL(int,int), which are both called by show(). Since I'm using show() and it doesn't call my reimplemented version of paintGL(MainWindow), I have no idea how to get my numbers on the screen.
Maybe this topic seems either rather complicated or idiotic to some more experienced users. I would, however, be very thankful for any hints regarding my own shortcomings. I also realize that my question is not entirely detached from Qt, but I thought it was more about c++ in general.
Thanks a lot from Berlin! -
Hi,
You should rather use setters on your 3D widget that you will call to set the various parameters you want, then call update() (from the setters) to trigger a redraw. That will make the overall design cleaner.