Important: Please read the Qt Code of Conduct -

error:Void Function Returning a Value ! Help!

  • #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QByteArray>
    #include <QProcess>
    #include <Windows.h>
    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <stdlib.h>
    using namespace std;
    MainWindow::MainWindow(QWidget *parent) :
        ui(new Ui::MainWindow)
        delete ui;
    void MainWindow::on_pushButton_clicked()
                QProcess proc;
                 proc.start("C:\\Program Files\\Git\\bin\\bash.exe", QStringList());
                 if (!proc.waitForStarted()) {
                     return 1;
                 proc.write("git init ");
                 QByteArray output;
                 if (proc.waitForReadyRead()) {
                     output += proc.readAll();
                 qDebug() << output;

    i keep getting this error :c2562 'MainWindow::on_push_button_clicked":'void' function keep returning a value. when i try to compile the code. I m new to qt and c++ , anyone here can tell me what is the cause of the error. thanks you

  • As the error says, you are returning a value in a void function.

    if (!proc.waitForStarted()) {
                     return 1;

    Replace this by

    if (!proc.waitForStarted()) {

  • @Wurgl


    Thank You! This really solved my problem !

Log in to reply