Hi,
You can use QCopChannel. You need a Qt App object though in your non-gui process.
1) In your gui application, start it as such QApplication app(argc,argv, QApplication::GuiServer);
2) then in your non-gui app you need this QApplication app(argc,argv, QApplication::GuiClient);
3) Get your server app (gui application) to start the client app. Using QProcess::start("clientapp"). Start it once the the server app has already entered the event loop. i.e for example when the window is shown.
4)You need to declare a QCopChannel object in your gui app, and receive the events from your client process. In my case I have a channel called "gpio", I declare the QCopchannel("gpio"). This registers the channel. Then whenever your non-gui app sends events to ("gpio") channel your gui app will receive them. You have to implement the receive event in your gui-app.
This is a brief explaination but it should set you in the right direction.
Then you need to send the Server app (your Qt app) a message. This is a helper function you don't need it.
int sendEventWData(char *string, unsigned char *buf, int size)
{
// QByteArray::fromRawData((const char *)buf,size);
sendQCopEvent
(GPIO,string,
QByteArray::fromRawData((const char *)buf,size
));
return 0;
}
int sendQCopEvent
( char *channel,
char *string,
const QByteArray &data
) {
{
return 0;
}
return -1;
}
int sendEventWData(char *string, unsigned char *buf, int size)
{
// QByteArray::fromRawData((const char *)buf,size);
sendQCopEvent(GPIO,string,QByteArray::fromRawData((const char *)buf,size));
return 0;
}
int sendQCopEvent( char *channel, char *string, const QByteArray &data)
{
if(QCopChannel::isRegistered(channel))
{
QCopChannel::send(channel, string, data);
QCopChannel::flush();
return 0;
}
return -1;
}
To copy to clipboard, switch view to plain text mode
Bookmarks