Results 1 to 8 of 8

Thread: how to count total numbers items in listwidget

  1. #1
    Join Date
    Dec 2010
    Posts
    27
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default how to count total numbers items in listwidget

    hello,

    I have used QlisiWidget in my application.
    I inserted items in it.
    Now i want to count items which are inserted .

    I used ui->listwidget->count() but it does not work..

    Can any one help me...???




    Thanks...

  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: how to count total numbers items in listwidget

    but it does not work..
    What do you mean by "doesn't work"?
    ==========================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
    Dec 2010
    Posts
    27
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: how to count total numbers items in listwidget

    hello,
    I mean i think it returns 0 .
    how can i make it??


    Thanks..

  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: how to count total numbers items in listwidget

    I mean i think it returns 0 .
    You think?
    Don't think - be sure!
    ==========================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
    Dec 2010
    Posts
    27
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: how to count total numbers items in listwidget

    hello,
    I test it using
    int i =ui->listWidget->count()
    label.setText(QString(i))

    And when print.It shows 0.

    Is it wrong????


    thanks.

  6. #6
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: how to count total numbers items in listwidget

    You can't use QString this way.

    Instead, use QString::number(i)

    Read the documentation.

  7. The following user says thank you to tbscope for this useful post:

    trupti (21st January 2011)

  8. #7
    Join Date
    Dec 2010
    Posts
    27
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt/Embedded Qt Jambi PyQt3 PyQt4
    Platforms
    Windows Symbian S60 Maemo/MeeGo

    Default Re: how to count total numbers items in listwidget

    hello,

    Thanks for reply....

    I want to show all listwidgetitems in QLabel. What i want is i set images as icon in items of listwidget. and now want to display this one by one icon image in my label..

    HOw can i do it???


    Thanks in advance...

  9. #8
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    28
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: how to count total numbers items in listwidget

    You can use HTML in QLabel.

    Like this:

    Qt Code:
    1. QLabel *myCoolLabel = new QLabel();
    2. myCoolLabel->setText("<img src=\"myFilePathOrResourceFilePath.extension\">");
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to get count of items in QListView column?
    By qt-closer in forum Qt Programming
    Replies: 3
    Last Post: 25th October 2010, 14:40
  2. qlistwidget count of selected items
    By tpf80 in forum Newbie
    Replies: 4
    Last Post: 10th December 2009, 13:31
  3. Total time in QTimer
    By martisho in forum Qt Programming
    Replies: 4
    Last Post: 14th November 2009, 08:24
  4. Qt listView total height
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 18th April 2008, 18:16

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
  •  
Qt is a trademark of The Qt Company.