Results 1 to 5 of 5

Thread: send & recuve via socket

  1. #1
    Join Date
    Nov 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: send & recuve via socket

    Is all the code in a .cpp file?
    If so, you explicitly need to add the following line to the end of your .cpp file, clean the project, run qmake again and rebuild the project.

    I'm assuming the .cpp file is called main.cpp
    Qt Code:
    1. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    Easier would be to put the class definition in a header file, then moc will be invoked automatically.

  3. #3
    Join Date
    Nov 2010
    Posts
    10
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: send & recuve via socket

    I wrote it in main.cpp.

    what is te meaning of moc at "main.moc"

    is my way correct for connecting to the serve?

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: send & recuve via socket

    Quote Originally Posted by nima View Post
    I wrote it in main.cpp.

    what is te meaning of moc at "main.moc"
    It's the meta object compiler. It makes it possible to use Qt signals and slots, among other things.

    is my way correct for connecting to the serve?
    Your slot connection is not correct.
    The slot is not part of the app.

    You also need to create an object based on Qconnect.

    Might I suggest your first learn c++?

  5. #5
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: send & recuve via socket

    tbscope speaks the truth: Please learn how to write a basic Qt application before trying to do socket programming - if you structure your program correctly and actually create an instance of the class that contains your slot, you would have a much better chance of your code doing what you want.

    (This should really be in the newbie forum, too)

Similar Threads

  1. qt TCP socket
    By ketan in forum Qt Programming
    Replies: 3
    Last Post: 20th November 2009, 11:17
  2. bug in Qt socket
    By dognzhe in forum Qt Programming
    Replies: 7
    Last Post: 12th June 2009, 07:36
  3. Replies: 7
    Last Post: 29th May 2009, 08:58
  4. TCP Socket with Qt4.2
    By Walsi in forum Newbie
    Replies: 3
    Last Post: 20th September 2007, 05:35
  5. bad UDP socket :(
    By chaosgeorge in forum Qt Programming
    Replies: 1
    Last Post: 11th December 2006, 02:55

Tags for this Thread

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.