×

Discussion Board

Results 1 to 14 of 14
  1. #1
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Question QlistWidegetItem Data

    Dear All,
    I am using Qlistwidgetitem to enter the my number,but number is entering in to list only once,, if i add again without doing any other operation,the applications is crashing on line (str==NULL) in second time why?
    Code:
    AddText()
    {
         QString str(ui.lineEdit->text());
         TPtrC MsgPtr (static_cast<const TUint16*>((str).utf16()), (str).length());  
         TBuf<50> buf;
         buf.Copy(MsgPtr);
         
         CleanupStack::PushL(iArray1);
         if ( str==NULL )
         	{
         	//--
         	return;
         	}
         else
         	{
    			 iArray1->AppendL(buf);
    			 TInt Count = iArray1->Count();
    			 TBuf<100> buf1;
    			 TBuf<100> CBuf;	
    			 CBuf.AppendNum(Count);
    			
    
    			 for(TInt i=0;i<Count;i++)
    				 {
    					 buf1.Copy(iArray1->MdcaPoint(i));
    					
    					 QString qString((QChar*)buf1.Ptr(),buf1.Length());
    					 QListWidgetItem *widgetitem1 = new QListWidgetItem(ui.listWidget);
    					 widgetitem1->setText(qString);
    					 widgetitem1->setCheckState(Qt::Unchecked );
    					
    					 qString.clear();
    				 }
    			// iArray1++;
         	}	 
    	 buf.FillZ();
    	 buf.Zero();
    	 str.clear();
    	 ui.lineEdit->clear();
         CleanupStack::PopAndDestroy(1);
        }

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QlistWidegetItem Data

    Didn't check your code, but you can try str.isEmpty() as an alternative to str == NULL.

  3. #3
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QlistWidegetItem Data

    if i used str.isempty()
    i am getting Panic KERN-EXEC 3
    Error:

  4. #4
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QlistWidegetItem Data

    Error : is getting on this line

    iArray1->AppendL(buf);

    Panic E32USER-CBase 21

    while appending the data into buf second time its throwing the error.

  5. #5
    Super Contributor
    Join Date
    Mar 2008
    Posts
    1,481

    Re: QlistWidegetItem Data

    Hi,

    Could you try this?

    TBuf<50> buf(0);
    buf.FillZ()
    buf.SetLength(0)
    buf.Copy(MsgPtr);

  6. #6
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QlistWidegetItem Data

    thx Manbub But?
    Same Error:

    Error : is getting on this line

    iArray1->AppendL(buf);

    Panic E32USER-CBase 21

    while appending the data into buf second time its throwing the error.

    Code:
         QString str(ui.lineEdit->text());
         TPtrC MsgPtr (static_cast<const TUint16*>((str).utf16()), (str).length()); 
         TBuf<50> buf(0);
         buf.FillZ();
         buf.SetLength(0);
         buf.Copy(MsgPtr);
         
         //TBuf<50> buf;
         //buf.Copy(MsgPtr);
        
         
         if ( str.isEmpty() )
         	{
         	//---
         	return;
         	}
         else
         	{
    			 
    			 CleanupStack::PushL(iArray1);
    			 iArray1->AppendL(buf);
    			 TInt Count = iArray1->Count();
    			 TBuf<100> buf1;
    			 TBuf<100> CBuf;	
    			 CBuf.AppendNum(Count);
    			
    
    			 for(TInt i=0;i<Count;i++)
    				 {
    					 buf1.Copy(iArray1->MdcaPoint(i));
    					
    					 QString qString((QChar*)buf1.Ptr(),buf1.Length());
    					 widgetitem1 = new QListWidgetItem(ui.listWidget);
    					 widgetitem1->setText(qString);
    					 widgetitem1->setCheckState(Qt::Unchecked );
    					
    					 qString.clear();
    				 }
    			//iArray1++;
         	}	 
    	 buf.FillZ();
    	 buf.Zero();
    	 str.clear();
    	 iArray1->Reset();
    	 ui.lineEdit->clear();
             CleanupStack::PopAndDestroy(1);
    	 //Clear();

  7. #7
    Super Contributor
    Join Date
    Mar 2008
    Posts
    1,481

    Re: QlistWidegetItem Data

    Hi,

    SDK says:
    This panic is raised by any operation which accesses an element of an array by explicit reference to an index number, for example, the Delete(), InsertL() and At() member functions or the operator Operator[]. It is caused by specifying an index value which is either negative or is greater than or equal to the number of objects currently within the array.

    Could you mention how is your iArray1? Can it be fixed and you are appending more there?

  8. #8
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QlistWidegetItem Data

    thx Manbub.
    yes i seen that panic 21 description in the SDK .
    array index is not incrementing properly in the second time .
    u have any idea how to resolve this?

  9. #9
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: QlistWidegetItem Data

    Quote Originally Posted by damodharan View Post
    thx Manbub.
    yes i seen that panic 21 description in the SDK .
    array index is not incrementing properly in the second time .
    u have any idea how to resolve this?
    Could you please show definition of iArray1?

  10. #10
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QlistWidegetItem Data

    yes,thx for u r reply Daniil,

    CDesCArray *iArray1;
    iArray1 = new (ELeave) CDesCArrayFlat(10);

  11. #11
    Super Contributor
    Join Date
    Mar 2008
    Posts
    1,481

    Re: QlistWidegetItem Data

    Try to make it as member variable so it does not go out of scope

  12. #12
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QlistWidegetItem Data

    thx Manbub,but same problem

  13. #13
    Super Contributor
    Join Date
    Mar 2008
    Posts
    1,481

    Re: QlistWidegetItem Data

    -Make it as member variable
    -Don't push it to cleanupstack
    -Add as much stuff as you want
    -In destructor, you do the clean up (delete the memory, See SDK help for more)

  14. #14
    Regular Contributor
    Join Date
    Oct 2008
    Posts
    323

    Re: QlistWidegetItem Data

    thx Mahbub & thx for all

    issue resolved

Similar Threads

  1. byte[] data transfer between J2ME and .NET Web Service?
    By kadir950 in forum Mobile Java General
    Replies: 1
    Last Post: 2010-04-30, 08:31
  2. Some data lost while receiving data from server
    By 182guide in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2010-03-09, 20:04
  3. How do pys60 received data continuously?
    By william.xiamen in forum Symbian
    Replies: 2
    Last Post: 2010-03-02, 18:57
  4. Replies: 3
    Last Post: 2008-09-09, 04:53
  5. Replies: 1
    Last Post: 2007-04-17, 10:47

Posting Permissions

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