Results 1 to 4 of 4

Thread: [Solved]I can't make QProcess work

  1. #1
    Join Date
    Jan 2016
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default [Solved]I can't make QProcess work

    I am trying to get a Linux console output. Here is my code
    Qt Code:
    1. p.start("gsettings get org.gnome.desktop.wm.preferences theme");
    2. QString p_stdout = p.readAllStandardOutput();
    3. p.waitForFinished();
    4. qDebug()<<"theme ="<<p_stdout;
    To copy to clipboard, switch view to plain text mode 
    in terminal, I get Ambiance output which is my current theme. But QT terminal gives theme ="" output.
    What am I doing wrong?
    Thanks
    Last edited by Nirvana; 22nd January 2016 at 22:40.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: I can't make QProcess work

    You are reading all available output before the program is run. The program does not actually start until your code reaches an event loop, either the main one or the one provided by waitForFinished(). Swap line 2 and 3.

  3. #3
    Join Date
    Jan 2016
    Posts
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11

    Default Re: I can't make QProcess work

    Thank you! It does work now.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I can't make QProcess work

    And the command should be "gsettings", the other strings should be the command's arguments as a QStringList.

    Cheers,
    _

Similar Threads

  1. QProcess does not work in service
    By yasjera in forum Qt Programming
    Replies: 5
    Last Post: 6th June 2014, 12:03
  2. IPC using QProcess , connect and finish does not work
    By PstdEr in forum Qt Programming
    Replies: 1
    Last Post: 28th April 2013, 01:43
  3. QProcess::start not work in windows 7
    By renocz in forum Qt Programming
    Replies: 0
    Last Post: 3rd April 2013, 15:47
  4. cant make QSound work
    By akon in forum Newbie
    Replies: 8
    Last Post: 19th March 2009, 16:34
  5. how to make these contents work??
    By srohit24 in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2009, 15:02

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.