Hi Rajesh,
The code segment u gave is not working for me. I think it is not compatible with qt3. Anyway thanx for the help.
Hi Rajesh,
The code segment u gave is not working for me. I think it is not compatible with qt3. Anyway thanx for the help.
Hi kenny,
I have written Qt4 code.
try following code for Qt3:
QListViewItem *item;
item = AvailableParam_lb->findItem ( ChoosenParam_lb->currentItem()->text(), 0, QListView::ExactMatch | Qt::CaseSensitive )
if(item != NULL)
delete item; // or AvailableParam_lb->removeItem( item );
Rajesh Kumar Singh
Bangalore, India.
Qt Search
Must Watch:
See how we can connect digital world objects to our day to day life….
Hi Rajesh,
I think I have narrowed down the problem. I am Inserting items to the List Box Using InsertItem Method. Which is a int. All other statements for comparison, manipulation etc go thro the currentText() or other Text() Methods which is QString. So I think if we give data to the list box as text then it will solve the problem.
I put a printf statement right after entering the values using InsertItem() and to my horror is is showing (NULL);
So can anyone tell me how to Insert a Text to the List Box.
Regards
Kenny
Does the code I provided work (especially the last part)?
BTW. I don't see any "insertItem" method taking its content as an int...
Hi,
Sorry I think I am confusing myself and others. This is what I am doing.
I am loading values to the list box from the table in the first place.
The Table is in the main window and the list box is residing in another dialog box.
So to send data I am using the following code segment.
Qt Code:
b->ChoosenParam_lb->insertItem ( table1->text(i,0), -1 );To copy to clipboard, switch view to plain text mode
where
b is object to the dialog that holds the list box,
ChoosenParam_lb is the name of the dialog
and Table1 is the name of the Table.
The test statement and output are as follows
This is given immediately after this code
Qt Code:
s=b->ChoosenParam_lb->currentText();//Test printf("Choosen Param : %s\n",s);//TestTo copy to clipboard, switch view to plain text mode
O/P:- (null);
The Whole Code is For loading the values is given below
Qt Code:
//Insert Items From Table to List Box Which is in Parameter Selection Dialog const char *s; if (size1 >18) { a = size1-18; for (i=0; i<18; i++) { b->ChoosenParam_lb->setCurrentItem(i); //Test b->ChoosenParam_lb->insertItem ( table1->text(i,0), -1 ); s=b->ChoosenParam_lb->currentText();//Test printf("Choosen Param : %s\n",s);//Test } } else { for (i=0; i<size1; i++) { b->ChoosenParam_lb->insertItem ( table1->text(i,0), -1 ); } } if ( a!=0) { for (i=0; i<a; i++) { b->ChoosenParam_lb->insertItem ( table1->text(i,0), -1 ); } }To copy to clipboard, switch view to plain text mode
Please see this and tell me what wrong.
With Kind Regards
Kenny
Last edited by wysota; 19th February 2007 at 12:10. Reason: missing [code] tags
I don't understand what the problem you have, but I see that the NULL you get might be because current item may be invalid. If you have 0 items in your list and set the current item to 0 then you'll get NULL as there is no item with index 0. If you add an item then, the current item will still be invalid. Then you set the current item to 1, but there is no item with that index in the list box so again the current item is not valid. Then you add an item, but the current item is still empty, so you'll never get a current item this way. Try moving the setCurrentItem() statement after you insert the item or don't use the current item at all - what do you need it for? You can use QListBox::text() instead.
Hi Guys,
Sorry for confusing U all and myself.
The code has run.
My logic is rite.
Only thing is that it should have been placed in the Parent Dialog box rather than Child Dialog Box.
Regards
Kenny'
Bookmarks