C++ (Qt)QListWidgetItem *item = new QListWidgetItem(textEdit->toPlainText());listWidget->addItem(item);textEdit->clear();
QListWidgetItem *item = new QListWidgetItem(textEdit->toPlainText());listWidget->addItem(item);textEdit->clear();
QObject::connect(ui->listWidget, SIGNAL(activated(QModelIndex)), this, SLOT(slotus2()));
void test ::slotus2(){ ui->listWidget->setCurrentItem(ui->textEdit->(???));}
void test ::slotus2(){ QListWidgetItem* item = 0; QListWidgetItem::setFlags(Qt::ItemIsEnable); ui->textEdit-> ??? }
void QListWidget::itemDoubleClicked ( QListWidgetItem * item ) [signal]This signal is emitted with the specified item when a mouse button is double clicked on an item in the widget.See also itemClicked() and itemPressed().
void QAbstractItemView::doubleClicked ( const QModelIndex & index ) [signal]This signal is emitted when a mouse button is double-clicked. The item the mouse was double-clicked on is specified by index. The signal is only emitted when the index is valid.See also clicked() and activated().
#include "test.h"#include "ui_test.h"test::test(QWidget *parent) : QMainWindow(parent), ui(new Ui::test){ ui->setupUi(this); QObject::connect(ui->pushButton, SIGNAL(clicked()),this, SLOT(slotus())); QObject::connect(ui->listWidget, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(slotus2()));}test::~test(){ delete ui;}void test ::slotus(){ QListWidgetItem *item = new QListWidgetItem(ui->textEdit->toPlainText()); ui->listWidget->addItem(item); ui->textEdit->clear();}void test::slotus2(){ QListWidgetItem *item=0; ui->textEdit_2->setText(item->text());}