Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error:Void Function Returning a Value ! Help!

error:Void Function Returning a Value ! Help!

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • QT_QT_QTQ Offline
    QT_QT_QTQ Offline
    QT_QT_QT
    wrote on last edited by
    #1
    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include <QByteArray>
    #include <QProcess>
    #include <Windows.h>
    #include <iostream>
    #include <string>
    #include <cstdlib>
    #include <stdlib.h>
    #include<QDebug>
    
    using namespace std;
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    
    {
        ui->setupUi(this);
    
    
    }
    
    MainWindow::~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

    1 Reply Last reply
    0
    • W Offline
      W Offline
      Wurgl
      wrote on last edited by
      #2

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

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

      Replace this by

      if (!proc.waitForStarted()) {
                       return;
                   }
      
      QT_QT_QTQ 1 Reply Last reply
      0
      • W Wurgl

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

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

        Replace this by

        if (!proc.waitForStarted()) {
                         return;
                     }
        
        QT_QT_QTQ Offline
        QT_QT_QTQ Offline
        QT_QT_QT
        wrote on last edited by QT_QT_QT
        #3

        @Wurgl

        HI

        Thank You! This really solved my problem !

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved