I've been through a lot of material on the internet about this, but haven't found what I need. I want to make a reusable painting function in Qt. For example, I would have a
void paintRectangle(QPaintEvent*, int x, int y);
function, which I can call in a loop and draws a rectangle starting at the x and y coordinates. Is this possible? Could you please write down the draft/outline on how I should write it and how I can call it in the loop when it's ready? I really didn't find anything on this. Also, how would I call this function? What do I write in place of the QPaintEvent *
when calling?
As I've noticed, paintevents get called before any class constructors. Is this correct? I'd like to have a certain amount of rectangles on the screen, which is depending on an n
variable, which is being declared when a certain class gets instantiated. As of my current trials, it seemed that the n
was undefined when my fuction tried to paint anything.