I know that a similar question was asked, but I did not find an answer that fixes my problem.
I am adapting existing Qt code to add server functionality to the program that my company uses. To this end, I added a QTcpServer object to the existing dialog, call listen () and connect the slot to the newConnection emitter, for example:
.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(&m_Server, SIGNAL(newConnection()), this, SLOT(new_Connection()));
}
The main thing:
int main( int argc, char *argv[] )
{
QApplication app(argc, argv);
QConsole * _output_window = new QConsole(desktopRect);
_output_window->init();
_output_window->show();
return app.exec();
}
new_Connection () is never called, so I see no relevance, but here it is:
void QConsole::new_Connection()
{
}
This works great when my program starts listening on the specified port and if I connect to it the connection that it created, but new_Connection () is never called!
2005 , , , , , , ( ). , , Qt-. , - , , .
, , , waitForNewConnection(), , readReady() . , ?
, .