×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    30

    For meego .txt file could not read

    hi
    i wanna to read a .txt file in QT my file is place in qml folder .but i failed..rememer this code is running good for symbian and desktop application
    am i wrong at somewhere plz let me know here is code .....Test2 is my project name

    void GraphicsEngine::loadPawnLocations(){
    // bool isComment = false;
    QString sToken;
    int index;
    int x_pos = 0;
    int y_pos = 0;

    QFile file("qml/Test2/pawnPosition.txt");

    QStringList strings;

    if (file.open(QIODevice::ReadOnly | QIODevice::Text))
    {

    QTextStream in(&file);
    char tmp;
    in>>index;
    in>>tmp;
    in>>x_pos;
    in>>tmp;
    in>>y_pos;
    while (!in.atEnd() ) {

    if (index >= PathMap::JOURNY_CELLS
    && index < PathMap::JOURNY_CELLS + PathMap::HOME_STREET_CELLS) {

    pawnsInHomeStreet[index
    - PathMap::JOURNY_CELLS][X_POS] = x_pos;
    pawnsInHomeStreet[index
    - PathMap::JOURNY_CELLS][Y_POS] = y_pos;

    } /**
    * locations for the pawns in castle
    * */
    else if (index
    >= PathMap::JOURNY_CELLS + PathMap::HOME_STREET_CELLS) {
    pawnsInCastleLocations[index - PathMap::JOURNY_CELLS
    - PathMap::HOME_STREET_CELLS][X_POS] = x_pos;
    pawnsInCastleLocations[index - PathMap::JOURNY_CELLS
    - PathMap::HOME_STREET_CELLS][Y_POS] = y_pos;

    } /**
    * Normally traveling
    * */
    else {
    pawnLocations[index][X_POS] = x_pos;
    pawnLocations[index][Y_POS] = y_pos;
    }
    strings.clear();

    in>>index;
    in>>tmp;
    in>>x_pos;
    in>>tmp;
    in>>y_pos;



    }
    }else
    {
    exit(1);
    // qDebug()<<"file not open";
    }
    }

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    3,956

    Re: For meego .txt file could not read

    try with this path : /opt/Test2/qml/Test2/pawnPosition.txt

  3. #3
    Registered User
    Join Date
    Dec 2011
    Posts
    30

    Re: For meego .txt file could not read

    i tried this path but still failed...

    QFile file("/opt/Test2/qml/Test2/pawnPosition.txt");

    any other idea ...bt do remember old code is working fine for symbian ...

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    30

    Re: For meego .txt file could not read

    sorry sir it works.....thank u soo much ....
    i tried with space thats y it doesnt work ...again thanks
    QFile file("/opt/Test2/qml/Test2/pawnPosition.txt ");


    right way to play
    QFile file("/opt/Test2/qml/Test2/pawnPosition.txt");

Similar Threads

  1. Opening file in MeeGo not working?
    By jkosonen in forum Nokia N9
    Replies: 2
    Last Post: 2011-10-22, 11:18
  2. Replies: 2
    Last Post: 2010-10-22, 23:35
  3. Replies: 3
    Last Post: 2008-03-04, 11:22
  4. Create own ini file and read/use content of this file
    By kaiten-sushi in forum Symbian C++
    Replies: 6
    Last Post: 2007-03-26, 16:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •