Hy

I would like to ask someone for help. I wanted to make a gui server so I created a gui application and in main class I created my server (because if I created it in MainWindow class I had problems with incomingConnection). It was not a problem to connect server class with mainwindow class, but problem arises when I try to connect another object declared in server class with mainwindow, I do not know how to pass object address, so I ask for help. To further illustrate my problem I attached piece of code:

Qt Code:
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3. #include "server.h"
  4.  
  5. int main(int argc, char *argv[])
  6. {
  7. QApplication a(argc, argv);
  8. MainWindow w;
  9. w.show();
  10.  
  11. Server ServerTcp;
  12. QObject::connect(&ServerTcp,SIGNAL(SetInfo(QString)),&w,SLOT(GetInfo(QString)));
  13. ServerTcp.StartServer(&w);
  14.  
  15. return a.exec();
  16. }
  17.  
  18.  
  19.  
  20. #include "server.h"
  21. #include "client.h"
  22.  
  23. Server::Server(QObject *parent) :
  24. QTcpServer(parent)
  25. {
  26. }
  27.  
  28. void Server::StartServer(QMainWindow *object)
  29. {
  30. if(listen(QHostAddress::Any,1234)){
  31. obj = object;
  32. emit SetInfo("Started");
  33. }
  34. else{
  35. emit SetInfo("Not started!");
  36. }
  37. }
  38.  
  39. void Server::incomingConnection(int handle)
  40. {
  41. Client *clientT = new Client(this);
  42. connect(&clientT,SIGNAL(SetInfo(QString)),&obj,SLOT(GetInfo(QString)));
  43. clientT->SetSocket(handle);
  44. }
To copy to clipboard, switch view to plain text mode 

Thank you for reply