QTreeWidget перемещение строк со встроенными виджетами.
Код:
QTreeWidgetItem* item = new QTreeWidgetItem(ui->treeWidget);
item->setText(0, "firstItem");
QSpinBox* spBox = new QSpinBox(ui->treeWidget);
spBox ->setValue(1);
//order is important
ui->treeWidget->insertTopLevelItem(ui->treeWidget->topLevelItemCount(),item);
ui->treeWidget->setItemWidget(item, 1, spBox );
item = new QTreeWidgetItem();
item->setText(0, "secondItem");
spBox = new QSpinBox(ui->treeWidget);
spBox ->setValue(2);
ui->treeWidget->insertTopLevelItem(ui->treeWidget->topLevelItemCount(),item);
ui->treeWidget->setItemWidget(item, 1, spBox );
item->setText(0, "firstItem");
QSpinBox* spBox = new QSpinBox(ui->treeWidget);
spBox ->setValue(1);
//order is important
ui->treeWidget->insertTopLevelItem(ui->treeWidget->topLevelItemCount(),item);
ui->treeWidget->setItemWidget(item, 1, spBox );
item = new QTreeWidgetItem();
item->setText(0, "secondItem");
spBox = new QSpinBox(ui->treeWidget);
spBox ->setValue(2);
ui->treeWidget->insertTopLevelItem(ui->treeWidget->topLevelItemCount(),item);
ui->treeWidget->setItemWidget(item, 1, spBox );
Код:
QTreeWidgetItem* item = ui->treeWidget->takeTopLevelItem(0);
ui->treeWidget->insertTopLevelItem(1, item);
ui->treeWidget->insertTopLevelItem(1, item);