Results 1 to 5 of 5

Thread: Tell me what to do in following situation?

  1. #1
    Join Date
    Dec 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Tell me what to do in following situation?

    I am thinking of creating a software that will have two systems:

    1. Server code and Database
    2. Client code and GUI codes.

    When someone click the login button on my login page. I create a connection and connectToHost(). It gets connected. Then I need to know how can I get the data from database located on server system so that I can show the data on profile page.

    Let suppose I need to retrieve name , address and photo.

    Really need help regarding it!!!
    Last edited by codeartist; 28th May 2012 at 13:19.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: Tell me what to do in following situation?

    You need to design an application layer protocol which is understood both by server and client systems.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Dec 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: Tell me what to do in following situation?

    Thanks for the reply. Can you show me a sample example.

  4. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 106 Times in 103 Posts

    Default Re: Tell me what to do in following situation?

    pseudo-code:
    Qt Code:
    1. // client
    2. void requestUserData( int user_id )
    3. {
    4. socket->write( "GET_USER_DATA," + QString::number( user_id ) );
    5. }
    6.  
    7. void newDataReceived( void )
    8. {
    9. QString data( socket->readAll() );
    10. QStringList sl = data.split( "," );
    11.  
    12. if( sl.at( 0 ) == "USER_DATA" )
    13. {
    14. QString name = sl.at( 1 );
    15. QString address = sl.at( 2 );
    16. QString image = sl.at( 3 );
    17. }
    18. }
    19.  
    20. // server
    21. void sendData( QString name, QString address, QString image )
    22. {
    23. socket->write( "USER_DATA," + name "," + address + "," + image );
    24. }
    25.  
    26. void dataReceived( void )
    27. {
    28. QString data( socket->readAll() );
    29. QStringList sl = data.split( "," );
    30.  
    31. if( sl.at( 0 ) == "GET_USER_DATA" )
    32. {
    33. int user_id = sl.at( 1 ).toInt();
    34.  
    35. sendData( users[user_id].name, users[user_id].address, users[user_id].image );
    36. }
    37. }
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Dec 2011
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Default Re: Tell me what to do in following situation?

    Thanks! This is it! I needed this

Similar Threads

  1. Strange situation
    By Molier in forum Qt Programming
    Replies: 8
    Last Post: 1st December 2010, 22:00
  2. What design fits my situation?
    By caelestis in forum Newbie
    Replies: 1
    Last Post: 2nd February 2010, 04:20

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
  •  
Qt is a trademark of The Qt Company.