how to pass a double value from c++ to a qt user interface
Moved
Unsolved
General and Desktop
-
I have made a user interface using qt creator 5.9.1. I want to be able to connect it now to an external c++ program so that I can update the values of the double spinboxes. Could someone show a simple example of what code I would need to write to send the double value from the external c++ program. And what code I would need to write to receive that value in the qt program.
-
I mean a c++ program that is not on qt. I am using ubunto 16.04
-
-
Should be something like:
OtherProgram
#include <iostream> int main(){ double aNumber; std::cin >> aNumber; std::cout << "Doubled number: " << 2.0*aNumber; return 0; }
QtProgram
#include <QCoreApplication> #include <QProcess> #include <QByteArray> #include <QDebug> int main(int argc, char **argv) { const double magicNumber = 1.56; QCoreApplication app(argc,argv); QProcess otherProcess; otherProcess.start("OtherProgram.exe"); if (!otherProcess.waitForStarted()) return 1; otherProcess.write(QByteArray::number(magicNumber,'f')); if (!otherProcess.waitForReadyRead()) return 1; qDebug() << otherProcess.readAllStandardOutput(); if (!otherProcess.waitForFinished()) return 1; return 0; }