QT5.3 unable to automatically invoke the Incomingconnection function (4.7 does not have this problem)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.