Qlistwidget move up and down?
Unsolved
General and Desktop
-
For Down List:
QListWidgetItem *currentItem = ui->listWidget->takeItem(currentIndex);
ui->listWidget->insertItem(currentIndex+1, currentItem);
ui->listWidget->setCurrentRow(currentIndex+1);it move the items but remove the widget of currentIndex why ?
-
Hi
You mean you have widgets on the items via setItemWidget ? -
From Qt 5.13 onward you can use
ui->listWidget->model()->moveRow(QModelIndex(),currentIndex,QModelIndex(),currentIndex+1);
-
Hi
I think you have to handle that yourself.
Try to call
https://doc.qt.io/qt-5/qtreewidget.html#itemWidget
on currentItem and see if it still has it widget when you take it out. -
@anil_arise said in Qlistwidget move up and down?:
yes ;
setItemWidget(QListWidgetItem *item, QWidget *widget);REPENT!!!
Why are you using this?