PDA

View Full Version : Qt client/server architecture doesn't work for my embedded linux platform



wesley
14th August 2010, 00:16
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[])
{
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();
}



client code:


int main(int argc, char *argv[])
{
QApplication app(argc, argv, QApplication::GuiClient);

QLabel label_2;
label_2.showMaximized();

return app.exec();
}

wesley
14th August 2010, 00:21
and something I need to mention is I running Qt-4.5.3 on a arm-linux platform,
for Qt performance, I had most of Qt feature disabled.
Is this could be the problem?

see my qconfig file attached.

/WX

wesley
14th August 2010, 00:26
1. I also tried QProcess to start my client app, got the same result.

2. I testing the QCopChannel communication. It is ok if two channel object in the same QApplication(process), but if I create the channels in different QApplication(process), they can not receive each other.

So, it sound like that QCopChannel are broken by something ?

/WX

wesley
14th August 2010, 04:04
OK, after looking the fucking source code, I found that this is because I disable the QWS MultiProcess feature in my qconfig file.

It seems that the Qt maybe unstable if I disable lots of features.
Could somebody please help me to check my qconfig file(attached in this thread), and found out if any critical Qt kernel features are disabled?

Thanks....

/WX