Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8564887
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:17:53+00:00 2026-06-11T17:17:53+00:00

I am trying to run a command line program, gphoto2 from my Qt app

  • 0

I am trying to run a command line program, gphoto2 from my Qt app running on Linux, and read the results that it outputs to Standard Output and Standard Error.

The GUI in this proof of concept program is a single push button and a label that is used to display the output from Standard Error and Standard Output.

I’m having trouble connecting the QProcess::finished signal to the correct slot. I copied the arguments list from the finished() signal documentation in the header, the connect statement, and the function.

The function name is prefixed with the MainWindow:: class identifier.

mainwindow.h:

#ifndef MAINWINDOW_H
#define MAINWINDOW_H
    
#include <QMainWindow>
#include <QString>
#include <QProcess>
#include <QObject>
    
namespace Ui {
    class MainWindow;
}
    
class MainWindow : public QMainWindow
{
    Q_OBJECT
        
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void reply2();    
        
private slots:
    void on_pushButton_clicked();
    void on_cameraControlExit(int exitCode, QProcess::ExitStatus exitStatus);
    
    
private:
    Ui::MainWindow *ui;
    QProcess* cameraControl;
};
    
#endif // MAINWINDOW_H

mainwindow.cpp:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QProcess>
#include <QShortcut>
#include <QDebug>
        
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    cameraControl = new QProcess(this);            
}
    
MainWindow::~MainWindow()
{
    delete ui;
    cameraControl->close();
    delete cameraControl;
}
    
void MainWindow::on_pushButton_clicked()
{
    //connect the camera control finished signal to the slot that will read the exit code and
    //place the std output string from the process into a label on the form
    connect(cameraControl, SIGNAL(finished(int , QProcess::ExitStatus )),
            this, SLOT(MainWindow::on_cameraControlExit(int exitCode, QProcess::ExitStatus exitStatus)));
    
    //Disable the ui button do we don't get double presses
    ui->pushButton->setDisabled(true);
    
    //setup the gphoto2 arguments list
    QStringList args;      
    args.append("--capture-image-and-download");
        
    //start the camera control
    cameraControl->start("gphoto2",args);
    
    //wait for the process to finish or 30 seconds whichever comes first
    cameraControl->waitForFinished(30000);
}
    
void MainWindow::on_cameraControlExit(int exitCode, QProcess::ExitStatus exitStatus)
{
    qDebug() << cameraControl->errorString();
    qDebug() << cameraControl->readAllStandardError();
    qDebug() << cameraControl->readAllStandardOutput();
    
    ui->pushButton->setEnabled(true);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T17:17:55+00:00Added an answer on June 11, 2026 at 5:17 pm

    I believe the following will work:

    connect(cameraControl, SIGNAL(finished(int , QProcess::ExitStatus )), this, SLOT(on_cameraControlExit(int , QProcess::ExitStatus )));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that I run from the command line that looks like
I am trying to compile and run a program from the command line. When
I am trying to run a java program from command line. I tried following
I am trying to run a program from command line in ubuntu and I
I'm trying to start a C# program running, and then give it command from
I am trying to run a command-line command from inside my Delphi application. ShellExecute(Form1.Handle,
I'm trying to get my java program to run an svn command from the
I'm trying to run a command-line program and piping in a file. The command
I have some difficulties trying to run the python programs from cmd, or command-line.
I'm trying to build a command line program to run in the terminal of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.