qprocess

QProcess and shell : Destroyed while process is still running

帅比萌擦擦* 提交于 2019-12-01 03:56:32
问题 I want to launch a shell script with Qt. QProcess process; process.start(commandLine, QStringList() << confFile); process.waitForFinished(); if(process.exitCode()!=0) { qDebug () << " Error " << process.exitCode() << process.readAllStrandardError(); } else { qDebug () << " Ok " << process.readAllStrandardOutput() << process.readAllStrandardError(); } The result is : Ok : Result.... " "" QProcess : Destroyed while process is still running. This message does not appear every time. What is the

How to launch a QProcess with root rights?

守給你的承諾、 提交于 2019-11-30 16:23:18
I need to launch gphoto2 from a Qt program. I do this: QString gphotoProgram = "/usr/bin/gphoto2"; QStringList gphotoArguments; gphotoArguments << "--capture-image"; QProcess *gphotoProcess = new QProcess(this); gphotoProcess->start(gphotoProgram, gphotoArguments); but it never enters the Running state this way, as gphoto2 usually needs admin rights to be launched on command line. How can I start this QProcess with proper rights to make gphoto2 working? Edit: I precise that I would prefer the user to not have to enter a password, which means gksudo, kdesudo or any other graphical solution is

How to launch a QProcess with root rights?

时间秒杀一切 提交于 2019-11-30 16:17:46
问题 I need to launch gphoto2 from a Qt program. I do this: QString gphotoProgram = "/usr/bin/gphoto2"; QStringList gphotoArguments; gphotoArguments << "--capture-image"; QProcess *gphotoProcess = new QProcess(this); gphotoProcess->start(gphotoProgram, gphotoArguments); but it never enters the Running state this way, as gphoto2 usually needs admin rights to be launched on command line. How can I start this QProcess with proper rights to make gphoto2 working? Edit: I precise that I would prefer the

Qt Calling External Python Script

心已入冬 提交于 2019-11-30 05:27:28
问题 I am trying to write a GUI wrapper for one of my command line tools written in Python. It was suggested to me that I should use Qt. Below is my project's .cpp file: #include "v_1.h" #include "ui_v_1.h" #include<QtCore/QFile> #include<QtCore/QTextStream> #include <QProcess> #include <QPushButton> v_1::v_1(QWidget *parent) : QMainWindow(parent),ui(new Ui::v_1) { ui->setupUi(this); } v_1::~v_1() { delete ui; } void v_1::on_pushButton_clicked() { QProcess p; p.start("python script -arg1 arg1"); p

reading and writing to QProcess in Qt Console Application

若如初见. 提交于 2019-11-29 16:52:47
Noted: this appears to be a specific issue question but hopefully it can be edited for all to related to I need to interact with a QProcess object. The Problem: I am not getting any output from QProcess after calling QProcess:write(input) More Info: Going through the doc pages led me to create an example below: I have a script requesting user input, and finally displaying and appropriate message based on the user input. Testing: After adding a "log" feature to my script for testing, the following occurs: script executes script requests user input (confirmed by the 'first' qDebug() << p-

Cannot execute echo command in QProcess

雨燕双飞 提交于 2019-11-29 16:50:26
I want to launch a SCPI command in my device using netcat utility under Ubuntu 10.04 LTS with Qt. My code looks like: env = "echo TRIG | nc 192.168.1.100 23 -q1"; process1.execute(env); process1.waitForFinished(1000); This command does not return any data but simply triggers the data acquisition. If using terminal with same "echo TRIG | nc 192.168.1.100 23 -q1" command, everything works fine. From Qt, it does not work. The debug output is "TRIG | nc 10.0.3.250 23 -q1" ... so without an "echo". My device does not receive the TRIG command. Could you please advise what I'm doing wrong? Many

Set Environment Variables for startDetached() QProcess

旧巷老猫 提交于 2019-11-29 16:33:29
In Qt4, there is QProcess::setProcessEnvironment() for setting Env variables for the newly spawn process. However, QProcess::startDetached() is a static member function, so setProcessEnvironment() doesn't apply. How does one set Env variables for a detached process in Qt? Giuseppe Cardone It is a known old bug: http://bugreports.qt-project.org/browse/QTBUG-2284 . You need to overload startDetached function to support your own environment. Take a look at Qt sources to see how to do that: http://code.qt.io/cgit/qt/qtbase.git/tree/src/corelib/io?h=5.5 ( qprocess* files). Using Qt5.5 now, Run into

Embedding a terminal in PyQt5

你说的曾经没有我的故事 提交于 2019-11-29 12:56:05
So I've been trying to create my own terminal but that has been proven very glitchy and not professional looking. Then I stumbled across this code which is for PyQt4: #!/usr/bin/env python #-*- coding:utf-8 -*- import sys from PyQt4.QtCore import * from PyQt4.QtGui import * class embterminal(QWidget): def __init__(self): QWidget.__init__(self) self.process = QProcess(self) self.terminal = QWidget(self) layout = QVBoxLayout(self) layout.addWidget(self.terminal) #self.process.start( #'xterm',['-into', str(self.terminal.winId())]) # Works also with urxvt: self.process.start( 'urxvt',['-embed',

Start a process using QProcess

a 夏天 提交于 2019-11-29 00:30:35
I'm trying to start Microsoft word using QProcess as following: QString program = "WINWORD.EXE"; process->start(program); but nothing happens. winword.exe is on path (so when i type winword.exe word is openning up). Is it the right way to do so ? mosg may be code below will help you: QProcess *process = new QProcess(this); QString program = "explorer.exe"; QString folder = "C:\\"; process->start(program, QStringList() << folder); I think you are trying to execute program that doesn't consists in global $PATH windows variable, that's why winword.exe doesn't executes. Also you may need to define

get all running processes info using QProcess

五迷三道 提交于 2019-11-28 12:11:35
few days ago i asked about how to get all running processes in the system using QProcess. i found a command line that can output all processes to a file: C:\WINDOWS\system32\wbem\wmic.exe" /OUTPUT:C:\ProcessList.txt PROCESS get Caption this will create C:\ProcessList.txt file contains all running processes in the system. i wonder how can i run it using QProcess and take its output to a variable. it seems every time i try to run it and read nothing happens: QString program = "C:\\WINDOWS\\system32\\wbem\\wmic.exe"; QStringList arguments; arguments << "/OUTPUT:C:\\ProcessList.txt" <<"PROCESS"<<