I simulated a dynamical device like mass spring damper.the QT Solves the equation of motion in Real Time and displays the output. I want to use an Qapplication object,to display Data and the outputs in "Real time". I don't know What should I put the "signal type" " in connect command" for this aim.(The answer in my opinion will probably be one of the method of QGraphicsRectItem class - Something is changing here is RectItem Position).
the main class is:
#include "QTcpSocket"
#include "QHostAddress"
#include "QObject"
#include "QThread"
Pltaform::Pltaform()
{
GraphicMass = new Motion();
iTH = new QThread;
}
void Pltaform::run()
{
isRunning = true;
while (isRunning)
{
switch (&message)
{
case 1:
getWorldData();
break;
case 2:
calculateControls();
DisplayQGraphic();
sendPlatformData();
break;
case 3:
isRunning = false;
cout << "Simulation Finished." << endl;
break;
void Pltaform::DisplayQGraphic()
{
GraphicMass->pos_x = states(0);
GraphicMass->pos_y = states(1);
// connect
GraphicMass->moveToThread(iTH);
connect(GraphicMass,SIGNAL(?????),this,SLOT(move()));
iTH->start();
}
void Pltaform::move()
{
setPos(x()+GraphicMass->pos_x,y()-GraphicMass>pos_y);
}
and the Motion class is:
#include "QGraphicsScene"
#include "QGraphicsView"
#include "QGraphicsRectItem"
#include "QObject"
Motion::Motion()
{
// create an item to put into the scene
setRect(0,0,20,30);
setPos(x(),y());
pos_x = 0;
pos_y = 0;}