Results 1 to 5 of 5

Thread: QProcess *proc at top of source (global?)

  1. #1
    Join Date
    Feb 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default QProcess *proc at top of source (global?)

    I have QProcess working fine, but I wanted to declare "QProcess *proc" at the top of the source (.cpp) file, so it's visible in more than one event handler. This causes make errors and/or segfaults. I've tried "proc->start(appString,argList);", and tried preceding with "*", "&". I also tried "." in place of "->". (Using Qt4, by the way). Does anyone know how to do this? Forgive me if this has been asked before, I wasn't sure what to search to find the answer.

  2. #2
    Join Date
    Feb 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QProcess *proc at top of source (global?)

    I fixed it, never mind. At the top of the source file, I used "QProcess proc".
    In the "connect" line I used:
    "connect(&proc,SIGNAL(error(QProcess::ProcessError )),
    this,SLOT(onProcessError(QProcess::ProcessError))) ;"
    and another place I used "proc.setWorkingDirectory(wDir);" and
    proc.start(appString,argList);
    Now it builds, and no more segfault.

  3. #3
    Join Date
    Feb 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QProcess *proc at top of source (global?)

    I TAKE THAT BACK - I'm getting a SEGFAULT, forgot to look in the console. Ok, so any ideas what I'm doing wrong?

  4. #4
    Join Date
    Feb 2008
    Posts
    15
    Thanks
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QProcess *proc at top of source (global?)

    Ok, I finally figured it out. I looked in the book "C++ GUI Programming With Qt4" and found out the easy (and correct) way. In the header file's "private" section, I placed "QProcess proc". In the source file, I connected proc to the proces error event handler like so:
    connect(&proc,SIGNAL(error(QProcess::ProcessError) ),this,SLOT(onProcessError(QProcess::ProcessError) ));
    To start the process I used this:
    proc.start(appString,argList);
    This line of code IS NOT NEEDED AT ALL:
    QProcess *proc=new QProcess(this);
    Now the process error handler works, too! It's way different that Qt3, takes me a while to learn.

  5. #5
    Join Date
    Aug 2007
    Location
    Gorakhpur, India
    Posts
    254
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QProcess *proc at top of source (global?)

    The best way is defining a such variabe or object in .h header files.
    Anurag Shukla
    A man who never makes mistake is the man who never does anything! Theodre Rosvelt!

Similar Threads

  1. QProcess and Pipes
    By KaptainKarl in forum Qt Programming
    Replies: 1
    Last Post: 9th April 2007, 23:11
  2. QProcess / system call not working under linux. Why?
    By johnny_sparx in forum Qt Programming
    Replies: 12
    Last Post: 11th March 2006, 00:32

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.