Problem with connect



  • Hello! I'm getting some data from cmd process. The problem is when I click button opens empty window. When I click again data is displayed.

    Code:

    void TestSettings::runCommand(QStringList arguments)
    {
        connect(&process, &QProcess::readyReadStandardOutput, this, &TestSettings::readCmdData);
        connect(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished), this, &TestSettings::finishedProcess);
        process.start("cmd.exe", arguments);
    }
    
    void TestSettings::readCmdData()
    {
        data = process.readAllStandardOutput();
        emit testData(data);
    }
    
    void TestSettings::finishedProcess()
    {
        connect(this, &TestSettings::testData, &appTestWidow, &TestWindow::getTestData, Qt::DirectConnection);
        appTestWidow.show();
    }
    

    How to fix this problem? Thanks.



  • I fixed this issue by adding connect to constructor and now it's displays data at first button click.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.