Results 1 to 6 of 6

Thread: Why i can't get the file.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2006
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Why i can't get the file.

    Qt Code:
    1. //client.cpp
    2. //..........................
    3. connect(senderButton, SIGNAL(clicked()), this, SLOT(sendMessageSlot()));
    4. void Send::sendMessageSlot()
    5. {
    6.  
    7. QDataStream out(client);
    8. QFileInfo info(file->fileName());
    9. out << info.fileName() << currentSize;
    10.  
    11. while(!file->atEnd())
    12. {
    13. char schar[2048];
    14. if (currentSize >= 2048)
    15. {
    16. file->read(schar, 2048);
    17. client->write(schar, 2048);
    18. currentSize-=2048;
    19. }
    20. else if(currentSize < 2048)
    21. {
    22. file->read(schar, currentSize);
    23. client->write(schar, currentSize);
    24. break;
    25. }
    26. }
    27. file->close();
    28. }
    29. ------------------------------------------------------------------------------------
    30. //server.cpp
    31. //...........
    32. connect(server, SIGNAL(readyRead()), this, SLOT(newMessageSlot()));
    33. void Receive::newMessageSlot()
    34. {
    35. if (boo_new)
    36. {
    37. QDataStream in(server);
    38. in >> name >> allSize;
    39. boo_new = false;
    40. }
    41.  
    42. file = new QFile(QString("C:\\%1").arg(name), this);
    43. file->open(QIODevice::WriteOnly |QIODevice::Append);
    44.  
    45.  
    46. if (server->isReadable())
    47. {
    48. quint64 size = server->bytesAvailable();
    49. char buf[size];
    50. server->read(buf, size);
    51. file->write(buf, size);
    52. readSize += size;
    53.  
    54. }
    55. file->close();
    56. delete file;
    57. if (readSize == allSize)
    58. {
    59. QMessageBox::warning(this, "ok", QString::fromLocal8Bit("over"));
    60. return;
    61. }
    62. }
    To copy to clipboard, switch view to plain text mode 

    ----------------------------------------------------------
    I am from in china, my English is very ppor, pardon me!
    compile and run it.
    i can get file in server from client send in local area network
    buf i can't get file in server from client send in internet...

    why ?
    i did't understand English, please reply some correct codes...

    thank very very much............

    //if you want to make china friends, please add me
    //janlex@msn.com
    Last edited by wysota; 28th September 2006 at 13:06. Reason: missing [code] tags

Similar Threads

  1. Draging a non-existing file to the Windows Desktop
    By klaus1111 in forum Qt Programming
    Replies: 13
    Last Post: 20th September 2007, 11:47
  2. .ui file name and classname
    By Rekha in forum Newbie
    Replies: 3
    Last Post: 12th August 2006, 01:53
  3. SQLite-DB in a qrc file
    By Lykurg in forum Qt Programming
    Replies: 5
    Last Post: 31st July 2006, 19:24
  4. File permission QFile::WriteOther on Win Dos
    By patrik08 in forum Newbie
    Replies: 1
    Last Post: 13th June 2006, 14:16
  5. QHttp GET File & Password
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 11th June 2006, 13:04

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.