Results 1 to 9 of 9

Thread: Insert an item in an horizontal QListWidget

  1. #1
    Join Date
    May 2009
    Posts
    29
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Insert an item in an horizontal QListWidget

    Hi,
    How can I insert an item in an horizontal QListWidget in a specified position?

    Thank you! Dario

  2. #2
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert an item in an horizontal QListWidget

    What do you mean by horizontal QListWidget ??
    I guess you mean multiple column in one row...
    If yes, have a look at QTableWidgetor QTreeWidget instead

  3. The following user says thank you to aamer4yu for this useful post:

    satoshi (19th May 2009)

  4. #3
    Join Date
    May 2009
    Posts
    29
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Insert an item in an horizontal QListWidget

    I meant this:



    Code:
    Qt Code:
    1. G2_ThumbsList::G2_ThumbsList(QWidget *parent, unsigned int iconWidth, unsigned int iconHeight) : QListWidget(parent)
    2. {
    3. this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Ignored);
    4. this->setFixedHeight(116);
    5. this->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
    6. this->setMovement(QListView::Static);
    7. this->setGridSize(QSize(126, 116));
    8. this->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    9. this->setThumbsSize(iconWidth, iconHeight);
    10. this->setViewMode(QListView::IconMode);
    11. this->setWrapping(false);
    12. }
    13.  
    14. void G2_ThumbsList::addThumb(G2_Thumb *thumb)
    15. {
    16. this->addItem(thumb);
    17. }
    18.  
    19. void G2_ThumbsList::insertThumb(G2_Thumb *thumb, unsigned int position)
    20. {
    21. if(position < this->count())
    22. {
    23. // HERE...?
    24. }
    25. else
    26. {
    27. this->addItem(thumb);
    28. }
    29. }
    To copy to clipboard, switch view to plain text mode 

    (Note: G2_Thumb inherits QListWidgetItem)

    I think that QTableWidget and QTreeWidget don't suite my situation..

    Thank you! Dario

  5. #4
    Join Date
    May 2009
    Posts
    29
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Insert an item in an horizontal QListWidget

    up......

  6. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Insert an item in an horizontal QListWidget

    Qt Code:
    1. QListWidget::insertItem ( int row, QListWidgetItem * item )
    To copy to clipboard, switch view to plain text mode 
    ?

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

    satoshi (19th May 2009)

  8. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert an item in an horizontal QListWidget

    I think that QTableWidget and QTreeWidget don't suite my situation..
    Right. After seeing the pic u posted, it is clear you just need a simple QListWidget.
    Lykurg already gave the solution

  9. The following user says thank you to aamer4yu for this useful post:

    satoshi (19th May 2009)

  10. #7
    Join Date
    May 2009
    Posts
    29
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Insert an item in an horizontal QListWidget

    Quote Originally Posted by Lykurg View Post
    Qt Code:
    1. QListWidget::insertItem ( int row, QListWidgetItem * item )
    To copy to clipboard, switch view to plain text mode 
    ?
    Quote Originally Posted by aamer4yu View Post
    Right. After seeing the pic u posted, it is clear you just need a simple QListWidget.
    Lykurg already gave the solution
    I already tried this solution but it doesn't work I think there is a problem because QListWidget is for a vertical list.. the first parameter of insertItem is "int row", if I specify a column it doesn't work..

  11. #8
    Join Date
    May 2009
    Posts
    29
    Thanks
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Insert an item in an horizontal QListWidget

    Sorry, it works The problem wasn't this....

    Thank you!

  12. #9
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Insert an item in an horizontal QListWidget

    Could you post what was the problem, and how it got cleared ?
    May be it will help someone someday

Similar Threads

  1. Help on QListWidget InternalMove item signal
    By tho97 in forum Qt Programming
    Replies: 3
    Last Post: 14th February 2009, 01:13
  2. QListWidget and selecting an item
    By invictus in forum Newbie
    Replies: 4
    Last Post: 19th June 2007, 11:59
  3. Replies: 1
    Last Post: 19th April 2007, 22:23
  4. extract item from QListWidget
    By impeteperry in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2006, 19:41
  5. keypress while editing an item in QListWidget
    By Beluvius in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 09:56

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.