Results 1 to 12 of 12

Thread: An Implemented QHttp Object

  1. #1
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default An Implemented QHttp Object

    My problem is when I connect one of my login dialog's slots, which is to
    be executed when my Conn object has completed it's http request, however
    all it does is; making my dialog return Accepted().

    I have an object like this:
    Qt Code:
    1. class Conn : public QHttp {};
    To copy to clipboard, switch view to plain text mode 

    and a dialog like this:
    Qt Code:
    1. class Login : public QDialog, private Ui::login
    2. {
    3. Conn conn;
    4. ...
    5. private slot:
    6. void HttpDone(bool err);
    7. };
    To copy to clipboard, switch view to plain text mode 

    and in the Login's constructor I call this connect:
    Qt Code:
    1. if(c==0) {
    2. conn = new Conn;
    3. } else {
    4. conn = c;
    5. }
    6.  
    7. connect(conn,SIGNAL(done(bool)),this,SLOT(HttpDone(bool)));
    To copy to clipboard, switch view to plain text mode 

    Login::HttpDone looks like this:
    Qt Code:
    1. void
    2. Login::HttpDone(bool err)
    3. {
    4. if(err) { return; }
    5. XmlHnd *hnd = new XmlHnd();
    6. xml.setContentHandler(hnd);
    7. if(conn->Data()->size() < 2)
    8. {
    9. file = conn->Data();
    10. QXmlInputSource XFile(file);
    11. if(xml.parse(XFile))
    12. {
    13. if(hnd->srvErr())
    14. {
    15. QMessageBox *mb = new QMessageBox("Helhed",
    16. hnd->getValue("error"),QMessageBox::Critical,
    17. QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
    18. mb->exec();
    19. delete hnd;
    20. return;
    21. } else {
    22. conn->setcid(hnd->getValue("cid"));
    23. delete hnd;
    24. accept();
    25. }
    26. }
    27. }
    28. }
    To copy to clipboard, switch view to plain text mode 

    To me it seems like the slot is called at the time it is being connected to the
    http's done signal. Is this true, if so how can I make it behave different?
    Last edited by bhs-ittech; 18th August 2006 at 14:41. Reason: Updates Login::HttpDone()

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,518 Times in 1,388 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: An Implemented QHttp Object

    void QHttp::done ( bool error ) [signal]
    This signal is emitted when the last pending request has finished; (it is emitted after the last request's requestFinished() signal). error is true if an error occurred during the processing; otherwise error is false.
    Qt Code:
    1. if(!err) accept();
    To copy to clipboard, switch view to plain text mode 
    This looks like erroneous to me. If everything went ok, you accept the dialog and the rest of the code in Login::HttpDone() becomes never executed...
    J-P Nurmi

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

    bhs-ittech (18th August 2006)

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

    Default Re: An Implemented QHttp Object

    Do you invoke any conn's methods in that constructor?

  5. #4
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: An Implemented QHttp Object

    jacek: only Conn's constructor to make a pointer to it if there isn't one allready.

    jpn: thanks, I miss read that one.

    Edit: updated the code in HttpDone in my first post.

    even with the changes it still accept the dialog almost before it displays it.
    Last edited by bhs-ittech; 18th August 2006 at 14:04.

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

    Default Re: An Implemented QHttp Object

    Quote Originally Posted by bhs-ittech
    even with the changes it still accept the dialog almost before it displays it.
    But is this dialog really accepted or it just closes itself?

  7. #6
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: An Implemented QHttp Object

    Quote Originally Posted by jacek
    But is this dialog really accepted or it just closes itself?
    with a minor structual change to HttpDone, it should only accept if it recives
    valid data from the web server. And it seem to behave that way.

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

    Default Re: An Implemented QHttp Object

    Quote Originally Posted by bhs-ittech
    with a minor structual change to HttpDone, it should only accept if it recives
    valid data from the web server. And it seem to behave that way.
    I was asking about the dialog itself, not the way HttpDone works.

    How do you create that dialog?

  9. #8
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: An Implemented QHttp Object

    Quote Originally Posted by jacek
    I was asking about the dialog itself, not the way HttpDone works.

    How do you create that dialog?
    quote from 'int main(int,char**)
    Qt Code:
    1. Login *l = new Login;
    2. l->setServer("www.keenan.dk");
    3. l->show();
    4. // l->setFocus();
    5. if(l->exec() == QDialog::Accepted)
    6. {
    7. mb = new QMessageBox("Helhed","Login er endnu ikke understøttet.",QMessageBox::NoIcon,
    8. QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
    9. } else {
    10. mb = new QMessageBox("Helhed","Klik på OK for at lukke.",QMessageBox::NoIcon,
    11. QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
    12. }
    13. return mb->exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: An Implemented QHttp Object

    Quote Originally Posted by bhs-ittech
    Login *l = new Login;
    l->setServer("www.keenan.dk");
    l->show();
    ...
    if(l->exec() == QDialog::Accepted)
    You don't have to invoke show(), if you use exec().

    What does setServer() do?

  11. #10
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: An Implemented QHttp Object

    it calls QHttp's setHost

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

    Default Re: An Implemented QHttp Object

    Quote Originally Posted by bhs-ittech
    it calls QHttp's setHost
    Only? In that case this "set host" request will be processed immediately and since it is the last request, QHttp::done() will be emitted.

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

    bhs-ittech (18th August 2006)

  14. #12
    Join Date
    Aug 2006
    Posts
    25
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Thumbs up Issue resoled.

    Thanks a lot jacek,

    I'd be looking for an altanate way of setting the host/server
    perhaps with a
    Conn *conn = new Conn("<server name>");
    and then invoke
    Login *l = new Login(conn);

Similar Threads

  1. QHttp internal error
    By LubosD in forum Qt Programming
    Replies: 1
    Last Post: 16th August 2006, 10:57
  2. how to use QHttp inside QThread in Qt3
    By alusuel in forum Qt Programming
    Replies: 3
    Last Post: 14th July 2006, 12:19
  3. Passing Object to dll
    By ankurjain in forum Qt Programming
    Replies: 2
    Last Post: 1st April 2006, 10:50
  4. Signal-Slot, object instances
    By ct in forum Qt Programming
    Replies: 3
    Last Post: 16th February 2006, 20:08
  5. Using QSA: A very basic question
    By yogeshm02 in forum Newbie
    Replies: 3
    Last Post: 26th January 2006, 08:34

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.