I have two separate c++ projects that run simultaneously and exchange information between them using TCP/IP. The names of those two projects are "World" and "Platform". To display Data and output in Real time, I have created a Qapplication object inside "World" class. (I do not want to use Qt forms to create QGprahics view I just want to code it). TCP/IP works without any problems. here is my code:
main.cpp:
#include "QTcpServer"
#include "QTcpSocket"
#include "QApplication"
#include "QGraphicsScene"
#include "QTime"
World::World()
{
WorldSettings settings;
Sys = new Dynamics(settings);
}
void World::run()
{
while (!time->finished())
{
if (controlStatus)
{
sendWorldData();
getPlatformData();
}
displayData();
}
int World::displayData()
{ char *argv[] = {"a", "arg1", "arg2", NULL};
int argc = sizeof(argv) / sizeof(char*) - 1;
QApplication a(argc, argv);
QGraphicsScene * scene = new QGraphicsScene();
// create an item to put into the scene
QGraphicsRectItem * sag = new QGraphicsRectItem();
sag->setRect(0,0,10,15);
view->show();
return a.exec();
}
with run this file, in first step time, the widget viwe is display and then the program stops running.(In other words, the program stops in the first iteration). I expect the code I'm writing to behave like this:First, the widget is displayed and then the data are displayed in the corresponding graphic items, number displays, etc. and in every iteration of the code, these display objects are updated. In other words, I have a real time program that I need to display it's output data in real time.