nkint
12th June 2013, 10:57
Hi!
Sorry if this is a dumb question but I have no past experience with threads and/or network communication.
I'm making a simple tcp communication: I have a sender and I have a receiver.
For now I have 2 different project in QtCreator, one for the sender and one for the receiver. I'm testing the network communication in this way: I open the receiver and then and I open the sender.
But I'd like to have a single progect called SenderReceiverTest that open 2 window, one for the receiver, one for the sender, in the same QtCreator project.
First question: Is this single-project stuff a good idea?
Then...
If i have something like this:
#include <QtGui/QApplication>
#include "windowsender.h"
#include "windowreceiver.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QApplication a(argc, argv);
WindowReceiver r;
r.show();
WindowSender s;
s.show();
QObject::connect(&r, SIGNAL(windowClosed()), // custom virtual void closeEvent(QCloseEvent *e)
&s, SLOT(close()));
QObject::connect(&s, SIGNAL(windowClosed()), // custom virtual void closeEvent(QCloseEvent *e)
&r, SLOT(close()));
return a.exec();
}
Second question:
The two window are in the same thread, aren't they? I'd like to have the two windows in different thread for testing real async communication.. and for that I should have two dirrefent thread.. right? How can I do this?
Sorry if this is a dumb question but I have no past experience with threads and/or network communication.
I'm making a simple tcp communication: I have a sender and I have a receiver.
For now I have 2 different project in QtCreator, one for the sender and one for the receiver. I'm testing the network communication in this way: I open the receiver and then and I open the sender.
But I'd like to have a single progect called SenderReceiverTest that open 2 window, one for the receiver, one for the sender, in the same QtCreator project.
First question: Is this single-project stuff a good idea?
Then...
If i have something like this:
#include <QtGui/QApplication>
#include "windowsender.h"
#include "windowreceiver.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QApplication a(argc, argv);
WindowReceiver r;
r.show();
WindowSender s;
s.show();
QObject::connect(&r, SIGNAL(windowClosed()), // custom virtual void closeEvent(QCloseEvent *e)
&s, SLOT(close()));
QObject::connect(&s, SIGNAL(windowClosed()), // custom virtual void closeEvent(QCloseEvent *e)
&r, SLOT(close()));
return a.exec();
}
Second question:
The two window are in the same thread, aren't they? I'd like to have the two windows in different thread for testing real async communication.. and for that I should have two dirrefent thread.. right? How can I do this?