Results 1 to 7 of 7

Thread: Problem in printing all the listitems of listwidget

  1. #1
    Join Date
    Mar 2011
    Location
    New Delhi, India
    Posts
    31
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Unhappy Problem in printing all the listitems of listwidget

    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.

    Qt Code:
    1. for(int i=0; i<=listwidget->count(); i++)
    2. {
    3. QString bstr = listwidget->item(i)->text(); // but item() takes only const
    4. spf_in<<bstr<<"\n";
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

    Any help will be appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in printing all the listitems of listwidget

    // 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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Mar 2011
    Location
    New Delhi, India
    Posts
    31
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Problem in printing all the listitems of listwidget

    I tried just now with this code. It's giving the same error as i was getting before.

    error is:

    exited with code -1073741819

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in printing all the listitems of listwidget

    this is a runtime error not a compile error.
    Run in it a debugger, and see which line crashes.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Mar 2011
    Location
    New Delhi, India
    Posts
    31
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Re: Problem in printing all the listitems of listwidget

    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.
    Last edited by dipeshtech; 2nd May 2011 at 15:12.

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Problem in printing all the listitems of listwidget

    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.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  7. #7

    Default Re: Problem in printing all the listitems of listwidget

    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.

Similar Threads

  1. Problem in updating listwidget of friend class
    By dipeshtech in forum Qt Programming
    Replies: 19
    Last Post: 25th March 2011, 15:18
  2. Printing Problem
    By cutie.monkey in forum Qt Programming
    Replies: 0
    Last Post: 20th August 2010, 04:59
  3. Printing a ListWidget
    By viciv919 in forum Newbie
    Replies: 3
    Last Post: 9th March 2010, 09:47
  4. printing problem
    By #andi# in forum Newbie
    Replies: 0
    Last Post: 9th August 2009, 21:01
  5. ListWidget itemClicked problem
    By Keemosabi in forum Newbie
    Replies: 2
    Last Post: 11th August 2008, 22:29

Tags for this Thread

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.