Results 1 to 3 of 3

Thread: Odd network/variable problems

  1. #1
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Odd network/variable problems

    Well, I'm new to Qt, so this might be a very obvious question. However, I'm not new to C++, and it's like nothing I've ever experienced. I have the following function:
    Qt Code:
    1. void QSNForm::requestData()
    2. {
    3. bool passed = false;
    4. QString data = "", tdata;
    5. int linesRead = 0;
    6. setStatus("Requesting data...");
    7. QString query = "GET /file/files/keys123.txt HTTP/1.1\r\nHost: mysite.com\r\nConnection: Close\r\n\r\n";
    8. server->writeBlock(query.ascii(), (Q_ULONG)query.length());
    9. setStatus("Receiving data...");
    10. server->readLine();
    11. while((tdata = server->readLine()) != "" || linesRead < 2) {
    12. data += tdata;
    13. // QMessageBox::information(this, "data length", data);
    14. if(data.find(sn->text()) > -1) {
    15. passed = true;
    16. break;
    17. }
    18. linesRead++;
    19. }
    20. setStatus("Parsing data");
    21. QMessageBox::information(this, "data", data);
    22. if(passed) authenticate();
    23. else QMessageBox::warning(this, "Authentication failed", "You have entered an incorrect serial number. Please try again.");
    24. setStatus("Idle");
    25. }
    To copy to clipboard, switch view to plain text mode 
    Now, the peculiar thing is that if the QMessageBox::information() call inside the loop (line 13) is uncommented, everything runs fine (apart from the big ugly message boxes, of course). However, as soon as it is removed, data, as seen at the second QMessageBox::information() call (line 21), becomes empty. Surely this shouldn't happen?

    Using Qt 3.3 on Fedora.
    Last edited by Twey; 11th January 2006 at 19:39.

  2. #2
    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: Odd network/variable problems

    You don't wait until response arrives.

    What type is that server variable of?

  3. #3
    Join Date
    Jan 2006
    Posts
    21
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Odd network/variable problems

    QSocket*.
    That could explain a lot.

    /EDIT: Yes, fixed. Knew it would be something simple. Thanks
    Last edited by Twey; 11th January 2006 at 20:07.

Similar Threads

  1. problems creating toolbar...(do see the attachment)!
    By sumit in forum Qt Programming
    Replies: 15
    Last Post: 10th September 2008, 11:23
  2. flicker and wierd resize problems ...
    By momesana in forum Qt Programming
    Replies: 1
    Last Post: 12th May 2008, 18:00
  3. Replies: 2
    Last Post: 8th March 2007, 22:22
  4. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 15:39

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.