Results 1 to 9 of 9

Thread: QProcess readyRead() and readReadStandardOutput signals not triggered in kde

  1. #1
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QProcess readyRead() and readReadStandardOutput signals not triggered in kde

    The code below takes the command runs linux "root -spy -xprop _NET_ACTIVE_WINDOW", this command returns the id of the active window every time it changes. I would pick the return of this command and add it to a TextEdit. In ubuntu (GNOME) it works right, every time I switch the active window is the signal emitted readReadyStandardOutput and the result is added to TextEdit, but in Kubuntu (KDE), the signal readReadyStandardOutput is not emitted immediately, only after the alternate active window several times is that it is fired. I think it is a problem buffer I / O but can not solve it. When I use QIODevice:: Unbuffered, occours the problem: only write device. Does anyone know how to solve this problem?

    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. process = new QProcess(this);
    10. connect(process, SIGNAL(readyReadStandardOutput()), this, SLOT(appendText()));
    11. process->start("xprop -spy -root _NET_ACTIVE_WINDOW");
    12. }
    13.  
    14. void MainWindow::appendText(){
    15. ui->textEdit->append(process->readAll());
    16. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,716
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QProcess readyRead() and readReadStandardOutput signals not triggered in kde

    only after the alternate active window several times is that it is fired.
    It could be that its just time that takes the process to start.
    Try connecting a slot to the "started()" signal, and only then do the switching between windows, and see if you get the signals then.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess readyRead() and readReadStandardOutput signals not triggered in kde

    does not work, the process is already started, as I said the problem only occurs in kde, gnome works normal. Let me explain: the signal is issued only after I switch the window 10 times, then he inserts the ids of 10 windows in TextEdit, then, only after switching to 10 times he inserts again, it's like waiting to fill a buffer to send the signal.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 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 readyRead() and readReadStandardOutput signals not triggered in kde

    Maybe you are reading from the wrong channel? What is the current channel of the process?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    jemesa (28th October 2010)

  6. #5
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess readyRead() and readReadStandardOutput signals not triggered in kde

    Quote Originally Posted by wysota View Post
    Maybe you are reading from the wrong channel? What is the current channel of the process?
    is the default channel of the process, not changed, the code is exactly the one shown above. What I find strange is that it works on Linux distributions with gnome interface but not working on distributions with kde interface.

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 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 readyRead() and readReadStandardOutput signals not triggered in kde

    And what happens if you run xprop directly from the console? Do you get the output desired on both kde and gnome?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess readyRead() and readReadStandardOutput signals not triggered in kde

    Yes, it works with both gnome and kde, and when setting the QProcess channel for ForwardedChannels, the console output occurs in real time in both kde and gnome.

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 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 readyRead() and readReadStandardOutput signals not triggered in kde

    Are you sure the output goes to stdout and not stderr?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #9
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess readyRead() and readReadStandardOutput signals not triggered in kde

    I tried changing the channel mode to MergedChannels and not solved.

Similar Threads

  1. QUdpSocket readyRead() signal not triggered
    By deionut in forum Newbie
    Replies: 2
    Last Post: 26th October 2010, 18:19
  2. Replies: 3
    Last Post: 28th September 2010, 10:48
  3. QThread and signals (linux/UNIX signals not Qt Signals)
    By Micawber in forum Qt Programming
    Replies: 1
    Last Post: 28th November 2007, 22:18
  4. Replies: 2
    Last Post: 27th February 2007, 21:06
  5. QHttp and readyRead signals emit sequence
    By balitong in forum Qt Programming
    Replies: 4
    Last Post: 19th June 2006, 05:22

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.