PDA

View Full Version : Problem in printing all the listitems of listwidget



dipeshtech
30th April 2011, 12:59
I wish to print all the items of listwidget in a file. The listwidget is contained in a dialog.

I wanted to access the listwidget items row by row and print the name of items in a file. Kindly suggest some way to do this.




for(int i=0; i<=listwidget->count(); i++)
{
QString bstr = listwidget->item(i)->text(); // but item() takes only const
spf_in<<bstr<<"\n";

}



Any help will be appreciated.

high_flyer
2nd May 2011, 15:37
// but item() takes only const
its not taking a const parameter, the method is const.
your code should work.
Show the compiler error you get.

dipeshtech
2nd May 2011, 15:55
I tried just now with this code. It's giving the same error as i was getting before.

error is:

exited with code -1073741819

high_flyer
2nd May 2011, 16:00
this is a runtime error not a compile error.
Run in it a debugger, and see which line crashes.

dipeshtech
2nd May 2011, 16:06
My debugger is not working due to some reason. But, I have checked it manually by commenting the lines and then checking for output. I found the line containing item() method is causing the problem.

high_flyer
2nd May 2011, 16:42
This is not reliable.
I urge you to fix your debugger problem first, and run it in a debugger, anything else is a guessing game.

markjan1
17th August 2012, 22:13
I have a very strange problem while using my ListView.

Only a part of my adapter items are renderd in the listview on screen but when I interact with the listview (ie tries to scroll it) all items are renderd properly.