Results 1 to 13 of 13

Thread: problem in QProcess

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QProcess

    yes its running quickly ... after i execute gtk_demo separately it shows the output before showing the window ... its quick ..

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

    Default Re: problem in QProcess

    Could we see some more code of yours?

  3. #3
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QProcess

    my code or that Gtk code ..?

    my Qt code:
    Qt Code:
    1. timer2 = new QTimer(this);
    2. timer2->setSingleShot(TRUE);
    3.  
    4. timer_FS = new QTimer(this);
    5. timer_FS->start(300);
    6.  
    7. container2 = new QX11EmbedContainer(this);
    8. container2->setPalette(QPalette(Qt::red));
    9. container2->setAutoFillBackground(true);
    10.  
    11.  
    12. procc2 = new QProcess();
    13. procc2->setProcessChannelMode(QProcess::MergedChannels);
    14. connect(procc2, SIGNAL(readyReadStandardOutput()), this, SLOT(readFromStdout2()));
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. QHBoxLayout *layoout4 = new QHBoxLayout();
    2. layoout4->addWidget(container2);
    3.  
    4. mainFrame5->setLayout(layoout4);
    5.  
    6. connect(timer2, SIGNAL(timeout()), this, SLOT(embed2()));
    7. connect(FPSBackButton, SIGNAL(clicked()), this, SLOT(timeout_bg2()));
    8. connect(timer_FS, SIGNAL(timeout()), this, SLOT(timeout_FS()));
    To copy to clipboard, switch view to plain text mode 

    /*setFPScanner =1 will be set when a embed Button is clicked in my Qt app*/
    Qt Code:
    1. void
    2. MainWindow::timeout_FS(){
    3.  
    4. if(setFPScanner == 1)
    5. mainstackedWidget->setCurrentIndex(4);
    6. else if(embedFPScanner == 1)
    7. {
    8. QString program4 = "./gtk_demo2";
    9. //QString program4 = "./animate";
    10. QStringList arguments2;
    11. if(procc2->state() != QProcess::Running)
    12. {
    13. procc2->start(program4, arguments2);
    14. }
    15. }
    16.  
    17. }
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. void MainWindow::readFromStdout2()
    2. {
    3. int j = 4;
    4. bool ok;
    5. QString out;
    6. out = procc2->readAllStandardOutput();
    7. j = out.toInt(&ok, 16);
    8. printf("j =%d\n",j);
    9. if(j == 1)
    10. printf("device not connected\n");
    11. else{
    12. printf("the device connected\n");
    13. timer2->start(2000);
    14. }
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MainWindow::embed2()
    2. {
    3.  
    4. container2->embedClient(widedit->text().toInt(&ok, 16));
    5. }
    To copy to clipboard, switch view to plain text mode 

    /*this will be set setFpscanner when a back button in my Qt app is clicked*/
    Qt Code:
    1. void MainWindow::timeout_bg2()
    2. {
    3. timer_FS->stop();
    4. setFPScanner = 0;
    5. mainstackedWidget->setCurrentIndex(1);
    6. timer_FS->start();
    7. }
    To copy to clipboard, switch view to plain text mode 

    this is my whole code in that part i written .... if u find any error please help me ...

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

    Default Re: problem in QProcess

    And how do you output the data from the slave app?

  5. #5
    Join Date
    Sep 2008
    Location
    Bangalore
    Posts
    659
    Thanks
    116
    Thanked 42 Times in 41 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: problem in QProcess

    Quote Originally Posted by wysota View Post
    And how do you output the data from the slave app?
    the gtk window will print 1 using printf if the device is not connected else it print 0 .. externly running
    gtk_demo.c
    Qt Code:
    1. if(retval != FTR_RETCODE_OK){
    2. if(retryCountLevel1 <= MAX_RETRY_COUNT){
    3. FreeResource();
    4. usleep(MAX_RETRY_SLEEP);
    5. retryCountLevel1++;
    6. goto retry_level1;
    7. }else{
    8. dump_line(stdin);
    9. printf("1");
    10. FreeResource();
    11. return -1;
    12. }
    13. }
    14. printf("0\n");
    To copy to clipboard, switch view to plain text mode 
    this is the gtk code ..
    so i use
    my Qt app
    readyReadStandardOutput() for the process and i try to get that as
    Qt Code:
    1. int j = 4;
    2. bool ok;
    3. const char *str;
    4. QString out;
    5. out = procc2->readAllStandardOutput();
    6. ba = out.toLatin1();
    7. str = ba.data();
    8. //j = out.toInt(&ok, 16);
    9. printf("the string on returning:%s\n",str);
    10. if(strcmp(str,"1") == 0){
    11. printf("device not connected\n");
    12. }
    13. else{
    14. printf("the device connected\n");
    15. timer2->start(2000);
    16. }
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

    did u find any thing i done foolishly ...
    if so please help ..

Similar Threads

  1. QProcess problem
    By Mystical Groovy in forum Qt Programming
    Replies: 2
    Last Post: 2nd December 2008, 20:07
  2. QProcess and kfmclient exec problem
    By ramazangirgin in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2008, 08:31
  3. QThread and QProcess problem
    By codebehind in forum Qt Programming
    Replies: 13
    Last Post: 7th August 2007, 08:11
  4. Quoting problem with QProcess
    By the_bis in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2006, 11:24
  5. problem with qprocess
    By deekayt in forum Qt Programming
    Replies: 2
    Last Post: 13th June 2006, 13:30

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.