PDA

View Full Version : empty reply of a POST request



WhiteR
15th January 2016, 22:46
I have a piece of code that makes a POST request to a server and gets the reply. If I put this code into a class instantiated in my main application it works fine.


int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyClass*camera = new MyClass();
//In MyClass constructor is made the POST request and displayed the result
return app.exec();
};


If I put it into a shared library and use this library in my application, I receive always an empty reply. I know is not really very specific, but since the code works from the main application, I do not think is a problem with the code.
In my library I have a class like this:


class LINUXSDKSHARED_EXPORT LinuxSDK: public QObject
{
Q_OBJECT
...
public:
LinuxSDK(QObject *parent = 0);
~LinuxSDK();
...
public slots:
void onfinish(QNetworkReply *rep);

The SLOT is working, it is called. I tried with a QEventLoop to wait for a reply but it looks like waits forever. I work in Ubuntu. The status code of the reply is 0, meaning the connection was accepted and then closed gracefully (TCP FIN). Why was it closed?
Can you help me with some useful ideas?
Thanks

anda_skoa
16th January 2016, 09:39
And your main() is the same? Just the class defined in a library?

Cheers,
_

WhiteR
16th January 2016, 18:59
I think I solved it. I have derived MyClass from QMainWindow instead of QObject. It seams it works now