Hello, guys
I want to make my Qt embedded app work as client-server architecture,
a QApplication that start with "-qws" or create with "QApplication::GuiServer" would play as a server, and the others QApplication the create with "QApplication::GuiClient" play as a client.
start the server app first, and then start the client app.
the problems is:
1. In server code, I set the max window rect to QRect(100, 100, 400, 300) via QWSServer::setMaxWindowRect();
In server application, the rect of widget_1 is QRect(100, 100, 400, 300), that is correct.
But in client app, the label_2 show full screen. I think this is wrong.
if I use QWSServer::setMaxWindowRect in client app, the max rect of label_2 is ok.
2. I connect the qws window event signal to my custom slot, and debug the window name, the server widget_1(QWidget) come into this slot, but I don't see the label_2(QLabel) come.
It seems that the client application play as a server itself, not a client of my server app, so the client doesn't respond to the server.
what is going wrong with my code ?
see code below:
server code:
int main(int argc, char *argv[])
{
Server srv;
widget_1.showMaximized();
return app.exec();
}
#ifndef _SERVER_H_
#define _SERVER_H_
{
Q_OBJECT
public:
~Server();
Q_SIGNALS:
public Q_SLOTS:
protected:
private Q_SLOTS:
private:
};
#endif // _SERVER_H_
{
// init qws server
}
Server::~Server()
{
}
{
qDebug() << "Server::windowEventHandler" << window->name();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv, QApplication::GuiServer);
Server srv;
QWidget widget_1;
widget_1.showMaximized();
return app.exec();
}
#ifndef _SERVER_H_
#define _SERVER_H_
class Server : public QObject
{
Q_OBJECT
public:
Server(QObject *parent = NULL);
~Server();
Q_SIGNALS:
public Q_SLOTS:
protected:
private Q_SLOTS:
void windowEventHandler(QWSWindow *, QWSServer::WindowEvent);
private:
QWSServer *server;
};
#endif // _SERVER_H_
Server::Server(QObject *parent)
: QObject(parent)
{
// init qws server
server = QWSServer::instance();
QWSServer::setMaxWindowRect(QRect(100, 100, 400, 300));
connect(server, SIGNAL(windowEvent(QWSWindow*, QWSServer::WindowEvent)),
this, SLOT(windowEventHandler(QWSWindow*, QWSServer::WindowEvent)));
}
Server::~Server()
{
}
void Server::windowEventHandler(QWSWindow *window, QWSServer::WindowEvent eventType)
{
qDebug() << "Server::windowEventHandler" << window->name();
}
To copy to clipboard, switch view to plain text mode
client code:
int main(int argc, char *argv[])
{
label_2.showMaximized();
return app.exec();
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv, QApplication::GuiClient);
QLabel label_2;
label_2.showMaximized();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks