Results 1 to 5 of 5

Thread: Background process execution in Qt

  1. #1
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Background process execution in Qt

    Hi everyone,

    I would like to know if it is possible to launch a function or a process in backgroud mode.

    The idea is, that I have a function that takes a long time to finish, because It manages a big amount of data. And then, I don´t want to stop the program during its execution. So the idea is to run this function at the beginning of the program execution in background mode. Meanwhile, the user could interact with the application whitout knowing that there is another process running within this application.

    It is possible?

    Thanks!!

  2. #2
    Join Date
    Mar 2007
    Posts
    57
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Background process execution in Qt

    Did you take a look at QThread and QProcess?

  3. #3
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Background process execution in Qt

    It seems that you can execute external applications with QProcess, but Im not sure about methods of a class within your application

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Background process execution in Qt

    If it is only a function you can look at QtConcurrentRun.

  5. The following user says thank you to Lykurg for this useful post:

    locke (11th March 2010)

  6. #5
    Join Date
    Feb 2010
    Posts
    64
    Thanks
    18
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Background process execution in Qt

    Hi, QtConcurrentRun sounds very good, but I try:

    I call the function below from a method of the class MainWindow, so the object I provide in the fucntion si the "this" pointer.

    Qt Code:
    1. //original function is: bool MainWindow::myFunction(QString s);
    2.  
    3. QString dir = "Example";
    4.  
    5. QFuture<bool> future = QtConcurrent::run(this, &MainWindow::myFunction, dir);
    6.  
    7. bool result = future.result();
    To copy to clipboard, switch view to plain text mode 

    But it locks the program, and I need to finish it. Any idea??

    Thanks

Similar Threads

  1. RunTime Execution
    By hasnatzaidi in forum Newbie
    Replies: 3
    Last Post: 5th October 2009, 06:45
  2. Improper execution!
    By dreamh4k in forum Newbie
    Replies: 1
    Last Post: 19th September 2009, 02:08
  3. execution in QT
    By adamatic in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2009, 08:12
  4. How to communicate Qt Process with non-qt process
    By nrabara in forum Qt for Embedded and Mobile
    Replies: 9
    Last Post: 15th February 2009, 21:01
  5. execution of slots
    By smalls in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2006, 19:38

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