Qt Shadow build mode doesnt read txt file



  • Hi.
    My program reads values from a txt file and plots them in a widget.
    The normal build, without shadow build, works fine.
    If i activate the shadow build and run it with QT, the program just reads zeros.
    The strange thing is, if i run the .exe in the shadow build folder on my computer, it runs fine again.
    So the problem just occurs when i compile it with QT as a shadow build.

    Thanks in advance.


  • Qt Champions 2016

    Hi
    Sounds like you read from fixed path ?
    So when using shadow , it cannot find file.
    The reading zero part, sounds like the variable is just empty as nothing was read.

    But i'm only guessing.

    Shadow build just change the folder where the .exe is produced.
    Could be anything.

    You should show some code. How you open the text file etc.



  • vector<double> EKG2File::createEKGVector(int counterLine)
      {
    
        counterLine--;
        fstream readFile;
        readFile.open("EKGData.txt", ios::in); ////////////////!!!!
        vector<double> aGUI(7);
    
        int countBuf = counterLine;
    
    
          for (size_t i = 0; i <countBuf; i++)
          {
            readFile >> counterLine >> lA >> lL >> rA;
          }
    
    
        //Überspringen der bereits gelesenen Zeilen
    
        //Hochzählen für nächstes Mal
        //Erstellen des Vektors für die aktuelle Zeile
        readFile >> counterLine >> lA >> lL >> rA;
        EKG2File::berechneAbl(lA, lL, rA);
    
        std::cout << counterLine <<" "<< lA <<" "<< lL <<" "<< rA << '\n';
        //std::cout << counterLine <<" "<< abl1 <<" "<< abl2 <<" "<< abl3 << " " << aVL << " " << aVR << " " << aVF << '\n';
    
        aGUI[0]=counterLine;
        aGUI[1]=abl1;
        aGUI[2]=abl2;
        aGUI[3]=abl3;
        aGUI[4]=aVR;
        aGUI[5]=aVL;
        aGUI[6]=aVF;
    
        closeFile();
        return (aGUI);
      };
    
    QVector<double> x,abl1,abl2,abl3;
        vector<double> plotVector(7);
    
        graph_erstellen();
    
        do
        {
            QApplication::processEvents();
            //Stopp-Bedingung
            if(stoppVariable == 0)
            {
                graph_zuruecksetzen();
                break;
            }
    
            plotVector = werteVector.createEKGVector(i);///////////
            x.append(plotVector[0]);
            abl1.append(plotVector[1]);
            abl2.append(plotVector[2]);
            abl3.append(plotVector[3]);
    
            ui->Plot1->graph(0)->setData(x,abl1);
            ui->Plot1->replot();
    
            ui->Plot2->graph(0)->setData(x,abl2);
            ui->Plot2->replot();
            ui->Plot3->graph(0)->setData(x,abl3);
            ui->Plot3->replot();
    

    here is some code.The first part is the function to open the file and write the values in a vector.
    The second part is how i use these values, if you want to see that.
    I think the main problem is that he cant find the file.
    But as i said, the strange thing is, that he finds the file when i run the .exe in the shadow folder.
    I´ll write some code and look if Qt opens the file correctly.

    Thanks for your answer.



  • Ok, so i tried it with the direct path of the txt file and it works now.
    is there another way to open it in the current directory?
    i tried different options, like "./EKGData.txt" but it doesnt work.
    Whereas in the normal build this way (((readFile.open("EKGData.txt", ios::in); )))) works fine.



  • I solved it.
    The txt file had to be in D:\Programme\QT\MeineProjekte\build-3KG-Desktop_Qt_5_8_0_MinGW_32bit-Debug
    Not in D:\Programme\QT\MeineProjekte\build-3KG-Desktop_Qt_5_8_0_MinGW_32bit-Debug\debug !!


  • Qt Champions 2016

    Hi
    Good found.
    I normally use

    readFile.open(qApp->applicationDirPath()+"/"+"EKGData.txt", ios::in)

    Which means where exe is.

    This saves me for issues in case something change the current active path for the application
    and open("nopathfilename.txt" will fail.


Log in to reply
 

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