Results 1 to 5 of 5

Thread: Need a little help with QThread

  1. #1
    Join Date
    Sep 2009
    Posts
    64

    Default Need a little help with QThread

    so i have a class that is used to upload and download files from an ftp server.

    The class inherits QThread, so i initialize my ftp class in my constructor, then when i try to do a save/download i first do this

    Qt Code:
    1. sftp.start(QThread::NormalPriority);
    2. sftp.get(filename);
    3. sftp.terminate();
    To copy to clipboard, switch view to plain text mode 

    that doesnt seem to work, my program locks up when i download the file, and of course, once i get the file, the program resumes.

    I then tried to initialize the ftp class in my constructor then immediately after initializing i call a
    Qt Code:
    1. sftp.start(QThread::NormalPriority);
    To copy to clipboard, switch view to plain text mode 

    i call my gets/sends then at the de-constructor of the class i call

    Qt Code:
    1. sftp.terminate();
    To copy to clipboard, switch view to plain text mode 

    i saw the same behavior. anyone have any suggestions?

  2. #2
    Join Date
    Sep 2009
    Posts
    64

    Default Re: Need a little help with QThread

    anyone have any suggestions?

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

    Default Re: Need a little help with QThread

    The constructor is run in the same thread as the calling thread, so you need to put the code that takes the time into the run method of the thread.

  4. #4
    Join Date
    Sep 2009
    Posts
    64

    Default Re: Need a little help with QThread

    I dont quite understand what you mean. where should i call a start on my new thread?

  5. #5
    Join Date
    Feb 2008
    Posts
    491
    Thanks
    12
    Thanked 142 Times in 135 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Need a little help with QThread


Similar Threads

  1. Need help in Qthread
    By skumar434 in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2009, 17:21
  2. need help in QThread()
    By wagmare in forum Qt Programming
    Replies: 3
    Last Post: 18th December 2008, 13:21
  3. Replies: 4
    Last Post: 26th June 2008, 18:41
  4. Spawn a QThread in another QThread
    By david.corinex in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2007, 12:54
  5. QThread help please
    By munna in forum Newbie
    Replies: 14
    Last Post: 31st May 2006, 04:54

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.