Results 1 to 6 of 6

Thread: QProcess

  1. #1
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile QProcess

    The code below in this SIGNAL clicked () a QPushButton. Every time I change the file mpl.tex I click the Button to update the file mpl.pdf, but this update only happens when click twice the Button. In the first click it shows the mpl.pdf old and the second click it updates.

    Qt Code:
    1. QProcess *latexfile = new QProcess;
    2. latexfile->start("latex", QStringList() << "mpl.tex");
    3. QProcess *psfile = new QProcess;
    4. psfile->start("dvips", QStringList() << "-ta4" << "-o" << "mpl.ps" << "mpl.dvi");
    5. QProcess *pdffile = new QProcess;
    6. pdffile->start("ps2pdf", QStringList() << "mpl.ps" << "mpl.pdf");
    7. QProcess *openpdf = new QProcess;
    8. openpdf->start("/usr/bin/acroread", QStringList() << "mpl.pdf");
    To copy to clipboard, switch view to plain text mode 

    Somebody has idea of as to make this?
    Thanks.
    Last edited by jpn; 14th May 2008 at 19:53. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QProcess

    QProcess works asynchronously, so if you want to start a chain of commands, you can't do it like this. You have to wait until one commands finishes its execution before starting the next.

  3. #3
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess

    I delete the files mpl.dvi, mpl.ps and mpl.pdf. Modify the file mpl.tex open the program click on Button, who has the code below, and it shows that the mpl.pdf delete previously. I do not understand. This file is updated only when mpl.pdf click for the second time the Button.

    Qt Code:
    1. void Mpl::openPdf()
    2. {
    3. QProcess *latexfile = new QProcess;
    4. QProcess *psfile = new QProcess;
    5. QProcess *pdffile = new QProcess;
    6. QProcess *openpdf = new QProcess;
    7.  
    8. latexfile->start("latex",QStringList() << "mpl.tex");
    9. if (latexfile->waitForStarted())
    10. cout << "Erro" << endl;
    11. psfile->start("dvips", QStringList() << "-ta4" << "-o" << "mpl.ps" << "mpl.dvi");
    12. pdffile->start("ps2pdf", QStringList() << "mpl.ps" << "mpl.pdf");
    13. openpdf->start("/usr/bin/acroread", QStringList() << "mpl.pdf");
    14. }
    To copy to clipboard, switch view to plain text mode 
    Somebody can help me, please?
    Last edited by jpn; 15th May 2008 at 10:44. Reason: missing [code] tags

  4. #4
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess

    Quote Originally Posted by wysota View Post
    QProcess works asynchronously, so if you want to start a chain of commands, you can't do it like this. You have to wait until one commands finishes its execution before starting the next.
    Do not understand very well, I have to wait a while? How do this? How do I know whether the execution has ended?

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QProcess

    Take a look at QProcess API and see what signals it emits. Also I suggest reading all its docs and taking a look at examples if there are any. Anyway in your case I'd suggest using system() instead of QProcess, at least for some of the calls.

  6. The following user says thank you to wysota for this useful post:

    jaca (15th May 2008)

  7. #6
    Join Date
    Dec 2007
    Location
    Brazil
    Posts
    61
    Thanks
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QProcess

    Quote Originally Posted by wysota View Post
    Anyway in your case I'd suggest using system() instead of QProcess, at least for some of the calls.
    Really I did. Thanks.

Similar Threads

  1. QProcess & Lame
    By clive in forum Qt Programming
    Replies: 3
    Last Post: 4th August 2007, 19:37
  2. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  3. QProcess extremely slow on Windows?
    By Pepe in forum Qt Programming
    Replies: 2
    Last Post: 26th March 2007, 00:25
  4. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30
  5. QProcess in a QThread
    By chombium in forum Qt Programming
    Replies: 2
    Last Post: 11th January 2006, 15:52

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.