Results 1 to 4 of 4

Thread: how to use QHttp inside QThread in Qt3

  1. #1
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default how to use QHttp inside QThread in Qt3

    Hi,
    can anyone have any experience with Qhttp and QThread in Qt 3.5.

    I am tring to put Qhttp connection inside QThread, I would like to close the whole Http action into QThread run fucntion, however Qhttp works asynchronously so I have to wait inside run fucntion until http finish its work and this is the problem :/

    I created Qhttp object inside my thread, connected its signals to my thread, and in my run fucntion after starting the http action I am trying to wait for its finish ( flag is changed in the slots function)
    void MyThread::run()
    {
    m_pHttp->setHost(...
    m_pHttp->get(...


    while(m_bFlag)
    qApp->processEvents();

    processHttpResults();
    }

    any ideas?
    it seems to work, but the whole application behaves strangly when the network connection is lost
    wbr,
    alusuel

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to use QHttp inside QThread in Qt3

    QHttp needs a running event loop, which in Qt3 is present only in the GUI thread. Even if you create QHttp in a different thread, GUI thread still will be doing all the work and your application might crash randomly.

  3. The following user says thank you to jacek for this useful post:

    alusuel (14th July 2006)

  4. #3
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: how to use QHttp inside QThread in Qt3

    thanks,
    so there is no way in Qt3 to put the whole http action in worker thread ?

    wbr,
    ula

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how to use QHttp inside QThread in Qt3

    Quote Originally Posted by alusuel
    so there is no way in Qt3 to put the whole http action in worker thread ?
    Unfortunately in Qt3 it isn't possible, but it shouldn't be a big problem, since QHttp is asynchronous.

Similar Threads

  1. [Qt4.1] How to insert an image inside a Form?
    By Gonzalez in forum Qt Tools
    Replies: 5
    Last Post: 23rd September 2008, 11:20
  2. QThread help please
    By munna in forum Newbie
    Replies: 14
    Last Post: 31st May 2006, 04:54
  3. Replies: 4
    Last Post: 10th May 2006, 22:37
  4. [QT4] QThread and printing a QList<QPixmap>
    By KShots in forum Qt Programming
    Replies: 3
    Last Post: 24th April 2006, 21:44
  5. Is it possible to create a QThread without inheriting ?
    By probine in forum Qt Programming
    Replies: 6
    Last Post: 23rd March 2006, 22:51

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.