Results 1 to 9 of 9

Thread: problems starting process

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    8
    Thanked 541 Times in 521 Posts

    Default Re: problems starting process

    Declare proc as a member in your class, because the way you did it now is not correct. Now, proc is not visible in the scan function because it is declared in other function.

  2. #2
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: problems starting process

    Hi again,
    I created proc as a member of the class. In .h file:
    private:
    QProcess *proc; //I tried also with public: QProcess *proc;

    and then I did like this in the .cpp file:
    BTScanning::BTScanning( QWidget* parent, const char* name, WFlags fl )
    : QWidget( parent, name, fl )
    {
    proc = new QProcess(this);
    connect( proc, SIGNAL(readyReadStdout()), this, SLOT(scan()) );

    te_results = new QTextEdit( this, "te_results" );
    te_results->setGeometry( QRect( 250, 180, 341, 281 ) );

    pb_scan = new QPushButton( Menu, "pb_scan" );
    pb_scan->setGeometry( QRect( 40, 40, 112, 24 ) );

    // signals and slots connections
    connect( pb_scan, SIGNAL( clicked() ), this, SLOT( scan() ) );
    }

    the second connect is because I have the button and the action has to be when I click the button of the menu.
    The scan() function is now:
    void BTScanning::scan()
    {
    proc->addArgument("hcitool scan");
    proc->start();
    if (!proc->start())
    te_expl->insertParagraph(QString("proc is not running"),-1);

    te_results->append(proc->readStdout());
    }

    and it appears again the message "proc is not running" in te_expl area....
    I tried a lot of different combinations but nothing.....can you help me??

  3. #3
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: problems starting process

    I did It!!!!
    Now everything works perfectly. What I did is create the object process as a member of the main function ( thanks to marcel ). Then I created another function to connect the process to this slot.
    The way of doing It was:
    inside the scan() function I created the process, add the arguments and start it and then connect it to the other function using readyReadStdout().
    Finally the other function that I created is like this:

    QProcess *process = (QProcess*)sender();

    while(process->canReadLineStdout()){
    te_results->insertParagraph(process->readLineStdout(), -1);
    }

    if(process->normalExit()){
    te_results->insertParagraph(process->readStdout(), -1);
    }

    thanks to wysota for that.
    And thanks to everyone for your help.

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

    Default Re: problems starting process

    Isn't this by any chance a double thread?
    http://www.qtcentre.org/forum/f-newb...lems-6785.html

  5. #5
    Join Date
    Apr 2007
    Location
    Valencia, Spain
    Posts
    30
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: problems starting process

    Yes, It is, and I'm sorry about that. I thought that once I started in the newbie forum and people answered me, I can pass to the Qt Programming forum because the other thread was only for the firsts steps. I'm sorry but as I said, is the first time that I write in a forum like this one.
    I'm really really sorry. Where I have to continue? Well, I will continue in the newbie forum.
    Sorry again to everyone.

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

    Default Re: problems starting process

    Don't worry, it's not a problem. Just don't start multiple threads on the same subject. It's confusing and causes the need to repeat some of the explanations from the other thread and sometimes causes simmilar answers in both threads.

Similar Threads

  1. Check wheter a process is running
    By Lele in forum Qt Programming
    Replies: 1
    Last Post: 15th June 2006, 13:35
  2. QT4 Plugins - problems, problems
    By NormanDunbar in forum Qt Programming
    Replies: 6
    Last Post: 9th May 2006, 16:39
  3. Replies: 2
    Last Post: 26th April 2006, 11:43
  4. How to activate another process?
    By gtthang in forum Qt Programming
    Replies: 6
    Last Post: 3rd February 2006, 08:53
  5. Problems with threads and windows
    By SkripT in forum Qt Programming
    Replies: 15
    Last Post: 16th January 2006, 18:46

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.