Results 1 to 7 of 7

Thread: [QTcpSocket] Cannot create children for a parent that is in a different thread

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: [QTcpSocket] Cannot create children for a parent that is in a different thread

    eewww, why are you pasing QString by reference for logging calls? Not even const reference! QString should definitely be passed by value.

    If you slot doesn't get hit, first thing you should do is debug the connections - does qt give any error message? Then debug what happens after the signal.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  2. #2
    Join Date
    Feb 2011
    Posts
    354
    Thanks
    17
    Thanked 27 Times in 24 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Windows

    Default Re: [QTcpSocket] Cannot create children for a parent that is in a different thread

    Well, I think I found the issue. Passing QString by reference may be something that wasn't intended, but technically it works (slot will be invoked). I think, the problem is you emit signals before establishing connection.
    Qt Code:
    1. PollController *pollController = new PollController();
    2.  
    3. // you emit signals here !
    4. pollController->setup(1,1000);
    5.  
    6. Analyzer *analyzer = pollController->getAnalyzer();
    7.  
    8.  
    9.  
    10. QThread pollThread;
    11.  
    12. pollController->moveToThread(&pollThread);
    13.  
    14.  
    15.  
    16. Logger *logger = new Logger();
    17. // you establish connection here! doesn't even get called
    18. logger->setup(host,port,analyzer);
    To copy to clipboard, switch view to plain text mode 

    However, it seems to not have any relation to my post. G00d luck.

Similar Threads

  1. Replies: 3
    Last Post: 19th March 2011, 15:01
  2. Replies: 0
    Last Post: 14th April 2010, 15:03
  3. disable a parent and children in a tree model
    By qt_gotcha in forum Newbie
    Replies: 4
    Last Post: 9th July 2009, 06:49
  4. Replies: 6
    Last Post: 8th July 2009, 13:24
  5. Replies: 4
    Last Post: 1st May 2009, 11:00

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.