Results 1 to 2 of 2

Thread: QListWidgetItem move item with displayed Widget

  1. #1
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default QListWidgetItem move item with displayed Widget

    Hello,
    I try move item in QListWidget, but I have problem with the item that have displayed Widget. To put it simply I don't know how to move Widget displayed by one item and place it into other one.

    I use this code to move items in ListWidget:
    Qt Code:
    1. int pos = ui->listWidget->currentRow();
    2. if( pos == 0 ) return;
    3.  
    4. QWidget *cWidget = ui->listWidget->itemWidget( ui->listWidget->item( pos ) );
    5. ui->listWidget->removeItemWidget( ui->listWidget->item( pos ) );
    6.  
    7. QListWidgetItem *cItem = ui->listWidget->takeItem( pos );
    8. // cItem->setSizeHint( cWidget->sizeHint() );
    9.  
    10. ui->listWidget->insertItem( (pos - 1), cItem );
    11. ui->listWidget->setItemWidget( cItem, cWidget );
    12.  
    13. ui->listWidget->setCurrentItem( cItem );
    To copy to clipboard, switch view to plain text mode 
    But it seams like setItemWidget don't set the widget into item (item move, up in this case, but displayed widget is lost )

    Any help is more then appreciate.
    Regards.
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

  2. #2
    Join Date
    Dec 2008
    Location
    Poland
    Posts
    383
    Thanks
    52
    Thanked 42 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: QListWidgetItem move item with displayed Widget

    Do I miss something obvious or this can't be done that way?
    In the near future - corporate networks reach out to the stars. Electrons and light flow throughout the universe.
    The advance of computerization however, has not yet wiped out nations and ethnic groups.

Similar Threads

  1. Replies: 0
    Last Post: 2nd August 2010, 11:17
  2. QGraphicsView move item issues.
    By mrothe in forum Newbie
    Replies: 3
    Last Post: 28th June 2010, 16:23
  3. how to move item up and down in QListView
    By zhanglr in forum Qt Programming
    Replies: 3
    Last Post: 1st August 2008, 14:39
  4. How to move an item on a GraphicsScene
    By Holy in forum Qt Programming
    Replies: 17
    Last Post: 25th July 2008, 14:40
  5. QListWidgetItem remove an item
    By mattia in forum Newbie
    Replies: 4
    Last Post: 9th November 2007, 07:57

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.