Note that there are some explanatory texts on larger screens.

plurals
  1. POI just cannot get QTcpServer working (newConnection never called)
    primarykey
    data
    text
    <p>I know similar question to this have been asked, but I haven't found an answer that fixes my problem.</p> <p>I'm adapting some existing Qt code to add server functionality to a program my company uses. To that end I added a QTcpServer object to the existing dialog, call listen() and connect a slot to the newConnection emitter, like:</p> <pre><code> .h class QConsole : public QDialog { Q_OBJECT public: void init(); public slots: void new_Connection(); private: QTcpServer m_Server; } .cpp void QConsole::init() { m_Server.listen(QHostAddress::Any, 12346); QDialog::connect(&amp;m_Server, SIGNAL(newConnection()), this, SLOT(new_Connection())); } </code></pre> <p>Main is:</p> <pre><code> int main( int argc, char *argv[] ) { QApplication app(argc, argv); QConsole * _output_window = new QConsole(desktopRect); _output_window-&gt;init(); _output_window-&gt;show(); return app.exec(); } </code></pre> <p>new_Connection() never gets called so I can't see the relevance, but here it is: </p> <pre><code> void QConsole::new_Connection() { } </code></pre> <p>This works fine in that my program starts listening on the port specified and if I telnet to it a connection of sorts it made, but new_Connection() is never ever ever called!</p> <p>I've seen posts on this problem dating back to 2005 so it's obviously not a new thing, but what I haven't found is a satisfactory answer to the problem (or any answer actually). This has got everyone at work stumped, even the person that has written a Qt server program. I'm guessing that there is something fundamentally wrong with the existing framework, but I have no idea what it might be. </p> <p>I have been tearing my hair out for a day and a half over this, and the closes I got to success was using waitForNewConnection() which would actually return me a socket, but when I connected to the readReady() emitter, that was never fired either. So what would prevent these signals never getting called? </p> <p>Please spare my sanity and help me as much as you can.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload