Results 1 to 20 of 20

Thread: Assert problem in line edit

  1. #1
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Assert problem in line edit

    Hi All ,

    have a text file in the format
    #n X Y Z
    0 123 456 789
    1 321 654 987
    2 345 243 809
    ......
    .....
    ...... and so on

    now i am reading the contents of the datum number(n) and X Y Z values using QRegExp but if try to read i am getting ASSERT problem please help us here is my code and error msg

    void DatumForm::readfile()
    {


    QString result;
    QFile file( "datum.txt" );
    if ( file.open( IO_ReadOnly ) ) {
    QTextStream stream( &file );
    QString line;
    int linenumber = 0;
    while ( !stream.atEnd() ) {
    line = stream.readLine();
    QRegExp rx ( "^\\d\\d?$" );
    rx.search ( "Datumno_Val" );
    result = rx.cap ( 0 );
    resulttemp = result;
    printf( "%3d: %s\n", linenumber++, line.latin1() );
    //lines += line;

    }

    file.close();
    }
    }

    void DatumForm::init()
    {
    Datumno_Val = DatumVal;
    datumnolineEdit->setFocus();
    decimals_mm_datum = 3;
    readfile();

    QStringList lines = QStringList::split( FIELD_SEP, resulttemp );
    Datumno_Val = lines[0].toInt();
    qDebug ( "Datum number : %d",Datumno_Val);
    Xdatum_Val = lines[1].toDouble();
    xdatcountlineEdit->setText(QString::number( Xdatum_Val, 'f', decimals_mm_datum) );
    qDebug ( "Xdatum_Val : %4.3lf",Xdatum_Val);
    Ydatum_Val = lines[1].toDouble();
    qDebug ( "Ydatum_Val : %4.3lf",Ydatum_Val);
    Zdatum_Val = lines[1].toDouble();
    qDebug ( "Zdatum_Val : %4.3lf",Zdatum_Val);

    }

    #######Error Msg##########
    Key Press Event:: DATUM
    0: 0:123.000:456.000:789.000
    Datum number : 0
    ASSERT: "i <= nodes" in /usr/lib/qt3/include/qvaluelist.h (373)
    Xdatum_Val : 0.000
    ASSERT: "i <= nodes" in /usr/lib/qt3/include/qvaluelist.h (373)
    Ydatum_Val : 0.000
    ASSERT: "i <= nodes" in /usr/lib/qt3/include/qvaluelist.h (373)
    Zdatum_Val : 0.000
    Last edited by grsandeep85; 27th July 2009 at 07:17.
    Thanks & Regards
    Sandeep G.R.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    maybe lines is empty?
    try to add this line in your code
    Qt Code:
    1. void DatumForm::init()
    2. {
    3. ...
    4. QStringList lines = QStringList::split( FIELD_SEP, resulttemp );
    5. if (lines.isEmpty())
    6. return;
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by spirit; 27th July 2009 at 07:35.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    cant you see what message you get on assert failure? it must say index out of range or something.. from there you can get a hint... and plz use the [code] tags.

  4. #4
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    Hi Spirit,

    I tried this in my code

    if (lines.isEmpty())
    return;

    but i am not getting any errors and the thing is i am not able to read the Datum number line values please help me.
    Thanks & Regards
    Sandeep G.R.

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    does that mean that you don't get any assert messages after using that code?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. #6
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    Yes.. but my intension is to read the Datum number(n) line values by using QRegExp and then split that line, get the X Y Z values and store it in another variables. and my code is correct or any modifications has to be done.
    Thanks & Regards
    Sandeep G.R.

  7. #7
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    as I said your list lines is empty (QList::isEmpty returns true),
    that means that parse (DatumForm::readfile) method works wrong, because (probably) resulttemp also is empty.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  8. #8
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    But i am able to read the file contents in the console terminal as below

    Datum number : 0

    Xdatum_Val : 0.000

    Ydatum_Val : 0.000

    Zdatum_Val : 0.000
    0: 0:123.000:456.000:789.000

    1: 1:321.000:654.000:987.000

    2: 2:123.000:456.000:789.000
    Thanks & Regards
    Sandeep G.R.

  9. #9
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    you said that you have not get any assertation messages, but in your last post there are.
    can you attach compilable project?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  10. #10
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    but its size is around 2.8Mb project files how to upload this in the forum. Also if i use
    if (lines.isEmpty())
    return;
    i wont get assert message.
    Thanks & Regards
    Sandeep G.R.

  11. #11
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    in your readline() try to replace

    resulttemp = result;

    with

    resulttemp+ = FIELD_SEP+result;

  12. #12
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    Quote Originally Posted by grsandeep85 View Post
    but its size is around 2.8Mb project files how to upload this in the forum. Also if i use
    if (lines.isEmpty())
    return;
    i wont get assert message.
    ok, the try to do next
    Qt Code:
    1. void DatumForm::init()
    2. {
    3. ...
    4. QStringList lines = QStringList::split( FIELD_SEP, resulttemp );
    5. qDebug() << resulttemp;
    6. qDebug() << lines;
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 
    and show us what will you see in console.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  13. #13
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    if i try to use

    QStringList lines = QStringList::split( FIELD_SEP, resulttemp );
    qDebug() << resulttemp;
    qDebug() << lines;

    then i will get error message as

    /usr/lib/qt3/include/qglobal.h: In member function ‘void DatumForm::init()’:
    /usr/lib/qt3/include/qglobal.h:975: error: too few arguments to function ‘void qDebug(const char*, ...)’
    datumform.ui.h:55: error: at this point in file
    /usr/lib/qt3/include/qglobal.h:975: error: too few arguments to function ‘void qDebug(const char*, ...)’
    datumform.ui.h:56: error: at this point in file
    make: *** [datumform.o] Error 1

    then i used

    void DatumForm::init()
    {
    readfile();
    QStringList lines = QStringList::split( FIELD_SEP, resulttemp );
    // qDebug() << resulttemp;
    // qDebug() << lines;
    printf( "resulttemp=%s\n", resulttemp.latin1() );
    if (lines.isEmpty())
    return;

    Datumno_Val = lines[0].toInt();
    Xdatum_Val = lines[1].toDouble();
    Ydatum_Val = lines[2].toDouble();
    Zdatum_Val = lines[3].toDouble();

    }

    to print resulttemp and message displayed in the console as

    Key Press EventATUM
    0: 0:123.000:456.000:789.000
    1: 1:321.000:654.000:987.000
    2: 2:963.000:852.000:741.000
    3: 3:357.000:214.000:698.000
    resulttemp=::::
    drass:/home/dro_changed/dro_som1 #
    Thanks & Regards
    Sandeep G.R.

  14. #14
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    ah, I've just noticed that you use Qt 3. ok.
    as I see resulttemp contatins resulttemp=::::, that explains why lines is empty.
    Last edited by spirit; 27th July 2009 at 09:37.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  15. #15
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    btw, I think you reg exp is not exaclty correct, try to use this one: \d+.
    Last edited by spirit; 27th July 2009 at 09:47. Reason: updated contents
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  16. #16
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    I used QRegExp rx ( "(\\d+)" );

    even after that also i m get the message as

    Key Press EventATUM
    0: 0:123.000:456.000:789.000
    1: 1:321.000:654.000:987.000
    2: 2:963.000:852.000:741.000
    3: 3:357.000:214.000:698.000
    resulttemp=::::


    Please help me how to proceed further
    Thanks & Regards
    Sandeep G.R.

  17. #17
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    did you look at Qt Assistant, there is an example in QRegExp::search?
    Qt Code:
    1. QString str = "offsets: 1.23 .50 71.00 6.00";
    2. QRegExp rx( "\\d*\\.\\d+" ); // primitive floating point matching
    3. int count = 0;
    4. int pos = 0;
    5. while ( (pos = rx.search(str, pos)) != -1 ) {
    6. count++;
    7. pos += rx.matchedLength();
    8. }
    9. // pos will be 9, 14, 18 and finally 24; count will end up as 4
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  18. #18
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    Here i am not using fixed string,, even i went through the examples also.
    The format of the file is as below and user will be writing some more values into the file maximum is 99 points and simultaneously user need to read the values.

    Datum X Y Z
    0 123 456 789
    1 321 654 987
    2 345 243 809
    ......
    .....
    ...... and so on

    now i need to search for Datum number i.e., first column only then i need to read the corresponding line split the Datum, X, Y, Z values and store in 3 different variables.

    QRegExp rx ( "(\\d+)" );
    rx.search ( "Datumno_Val" );

    is my code is correct or not.
    Thanks & Regards
    Sandeep G.R.

  19. #19
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Assert problem in line edit

    if it doesn't work then it is not correct.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  20. #20
    Join Date
    Jul 2009
    Location
    Bangalore
    Posts
    68
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Assert problem in line edit

    Then how to proceed further is there any other method to perform this operation.
    Thanks & Regards
    Sandeep G.R.

Similar Threads

  1. Problem updating Line edit from a thread
    By raghvendramisra in forum Qt Programming
    Replies: 5
    Last Post: 3rd December 2007, 05:05
  2. Line Edit Controll problem
    By mansoorulhaq in forum Qt Programming
    Replies: 5
    Last Post: 31st October 2007, 08:33
  3. Replies: 8
    Last Post: 15th May 2007, 09:21
  4. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42
  5. Signal problem in Qline Edit
    By awalesminfo in forum Newbie
    Replies: 1
    Last Post: 3rd April 2006, 09:13

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.