m41n1
12th August 2008, 01:45
Hello everyone.
Well, I am going to start explaining what i wanted to get and then what I tried. This is basically because I don't know if i am doing the right thing. I have an agent-based software for finding solution to a given problem. A solution is given by a vector of id's and its graphical representation is a graph. All these agents have a pointer to the best solution so when one of them finds a better solution, updates the current "best solution". This is done by simulating parallelism, I mean, agent#1 executes its code, and when it finishes agent#2 proceeds. This way there's no problem updating the best solution found.
This software is text-based (a console app) so its really hard to 'understand' the solution. What i was intending to do is just to display this solution on a QMainWindows using QGraphicsView. So I thought I could create a class with a pointer to the best solution that could paint this solution every 2 secs (for example).
I developed a class 'paintable' that inherits from QMainWindow that contains methods to paint the solution. Then I tried creating another class 'SolDisplayer' that inherited from QThread and 'paintable'. The idea was to create a thread to paint this solution every x given seconds. But it seems it's not possible to have two classes inheriting from QObject. This way I thought I could avoid the use of QThread by using QTimer, but it doesn't work either. I don't know what else to try, maybe it's just this should not be done like this. ¿Could you gimme some ideas on how to do this?:(
In this example, I have two main classes, one for changing the vector and the other one for displaing it. This is the code of the classes, maybe it's something wrong. Anyway, both classes work separetedly. If i don't run the class that changes the vector, the display class works smoothy, but if i run that class that suffles the vector, no window is launched.:confused:
http://rafb.net/p/OsNbeN52.html
Well, I am going to start explaining what i wanted to get and then what I tried. This is basically because I don't know if i am doing the right thing. I have an agent-based software for finding solution to a given problem. A solution is given by a vector of id's and its graphical representation is a graph. All these agents have a pointer to the best solution so when one of them finds a better solution, updates the current "best solution". This is done by simulating parallelism, I mean, agent#1 executes its code, and when it finishes agent#2 proceeds. This way there's no problem updating the best solution found.
This software is text-based (a console app) so its really hard to 'understand' the solution. What i was intending to do is just to display this solution on a QMainWindows using QGraphicsView. So I thought I could create a class with a pointer to the best solution that could paint this solution every 2 secs (for example).
I developed a class 'paintable' that inherits from QMainWindow that contains methods to paint the solution. Then I tried creating another class 'SolDisplayer' that inherited from QThread and 'paintable'. The idea was to create a thread to paint this solution every x given seconds. But it seems it's not possible to have two classes inheriting from QObject. This way I thought I could avoid the use of QThread by using QTimer, but it doesn't work either. I don't know what else to try, maybe it's just this should not be done like this. ¿Could you gimme some ideas on how to do this?:(
In this example, I have two main classes, one for changing the vector and the other one for displaing it. This is the code of the classes, maybe it's something wrong. Anyway, both classes work separetedly. If i don't run the class that changes the vector, the display class works smoothy, but if i run that class that suffles the vector, no window is launched.:confused:
http://rafb.net/p/OsNbeN52.html