Results 1 to 4 of 4

Thread: ListWidget positions item

  1. #1
    Join Date
    Oct 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation ListWidget positions item

    Hello. I'm new to this forum and also to qt. I need some help with these. I use Qt 4.3.4 wint MinGW. I made a window which contain a QListWidget. I made a combobox from wich i add item to ListWidget wiht text and icon.I can move items in ListWidget where i want. I save the ListWidget saving the text item , icon item and the position item (row and column).
    The problem i have i that i made a function to load the item to list and put them to the position that were saved. I read in help and i found up that to insert a item to ListWidget to a certain posistion in list (where i want) i must user QListView::setPositionForIndex(QPoint &point,const QModelIndex &index) cont.
    to retreive the QModelIndex from QListWidgetItem i must use QListWidget::indexFromItem(QListWidgetItem *item) const..... both this function are protected. my problem is that i can't use them. i tried a lot of posibilities and nothig.
    Can someone help me? and tel my how i can use these functions togheter and insert the item at position that i want? Or if can tell me another way to insert intems into QListWidget at given position.. i mentioned that i have the position....

    thanks a lot

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: ListWidget positions item

    why you can't use this method
    void QListWidget::insertItem ( int row, QListWidgetItem * item )
    Inserts the item at the position in the list given by row.
    ?

  3. #3
    Join Date
    Oct 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: ListWidget positions item

    I use this function initialy to add items to list,but function add an item to a specific row not to specific position (row and column) in list. My listWdiget is in Icon mode so i can set an item every where i wish . I search on net and i found just one example to add an item to a QListWidget at specified coordonites. they use in example a derrived class of QListWidget in whicjh they use to add items to list using this function:
    QListView::setPositionForIndex(QPoint &point,const QModelIndex &index).

    I compile the example and it works.I put the listWidget in designer and try to use same function above and i get error that :
    1. i can't use listWidget->indexFromItem(QListWidgetItem *item) because is protected
    2. so with setPositionForIndex
    the compiler tells me that i can't use this function...i try to create a derivate class based on QListWidget an promote la listWidget from to designer to this classs...and nothig happens same message.. I wander if there is another method to insert item to list to a specified coordonates.

    thanks

  4. #4
    Join Date
    Oct 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation Re: ListWidget positions item

    I succed to use setPositionForIndex() to insert an intem to a specific position.the problem is that when i insert a second item tha first item is moved to 0,0 and last item remains at specific position.Mean always i insert a intem previous items lose their position and the last doesn't.i understan is about repaint() function...is any way to make previous items remain at their position while i insert a new item to the list?

    please help


    Thanks a lot.

Similar Threads

  1. View, Scene, Item and thread??
    By dungsivn in forum Qt Programming
    Replies: 5
    Last Post: 20th August 2008, 19:21
  2. Item in a DLL not getting events
    By Benne Gesserit in forum Qt Programming
    Replies: 11
    Last Post: 16th August 2008, 22:30
  3. Item Delegate Painting
    By stevey in forum Qt Programming
    Replies: 3
    Last Post: 9th May 2008, 07:37
  4. ListWidget horizontal scroll.
    By patrick772goh in forum Qt Tools
    Replies: 3
    Last Post: 17th July 2007, 07:32
  5. Replies: 1
    Last Post: 19th April 2007, 22:23

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.