Recently will qt4.7 a project moved to 5.3, encountered a few trouble, mainly this incomingconnection monitoring can not automatically call the problem, in 4.7 is completely no problem, to 5.3 can not, online also check the next, netizens are releasing the problem, but did not write a solution.
1. One-Step solution
That's what I wrote before:
void tftpxserver::incomingconnection (int socketdescriptor) { qdebug () << "incomingconnection ..."; Tftpxthread *thread = new Tftpxthread (socketdescriptor); Deletelater will release thread connect (threads, SIGNAL (finished ()), threaded, SLOT (Deletelater ())); Thread->start ();} int Tftpxserver::startlisten ()//by calling this function to automatically enter Incomingconnection to open a new thread, however there is no egg in QT5.3. { if (!this->listen (Qhostaddress::any, Tftpx_port)) { m_strerrmsg = QString ("Tftpxserver listen Fail."); return t_socket_listen_fail; } Qdebug () << "listen success."; return t_success;}
Later I tried to use the internal function to listen to, but with Tftpxserver object to listen directly, the above Startlisten () to kill, the external direct so that you can:
Mainwindow::mainwindow (Qwidget *parent): Qmainwindow (Parent), UI (new Ui::mainwindow) { ui-> SETUPUI (this); Serverinit ();}
int Mainwindow::serverinit () { m_server = new Tftpxserver (this); if (!m_server->listen (Qhostaddress::any, Tftpx_port)) { ui->textbrowseserverstatus->append (" Background server started, monitoring failed!!! "); return t_socket_listen_fail; }
return t_success;
}
You can also refer to your own demo:c:\qt\qt5.3.2\examples\qt-5.3\network\threadedfortuneserver to see the next
Http://www.cnblogs.com/luoxiang/p/4730215.html
QT5.3 unable to automatically invoke the Incomingconnection function (4.7 does not have this problem)