mnrao1230
22nd February 2012, 11:55
Hi,
I am new to QT. I have a problem- How to copy selected items of QListwidget to clipboard.
I tried the following -
void Properties::keyPressEvent(QKeyEvent *k)
{
if (k->matches(QKeySequence::Copy))
{
// I am getting the selected items from the QListWidget
QList<QListWidgetItem *> lw_temp = testWidget->lw_props_sample->selectedItems ();
int itemsCount = testWidget->lw_props_sample->selectedItems ().count();
QStringList strings;
for (int i = 0; i < itemsCount; ++i)
{
strings.append(lw_temp.value(i)); // I am getting problem in this line. How to get the string value from the list and append it to QStringList
}
QApplication::clipboard()->setText(strings.join("\n"));
}
Error: error C2664: 'append' : cannot convert parameter 1 from 'class QListWidgetItem *' to 'const class QString &' at line:
Please help me...
thanks in Advance,
Prabhakar
I am new to QT. I have a problem- How to copy selected items of QListwidget to clipboard.
I tried the following -
void Properties::keyPressEvent(QKeyEvent *k)
{
if (k->matches(QKeySequence::Copy))
{
// I am getting the selected items from the QListWidget
QList<QListWidgetItem *> lw_temp = testWidget->lw_props_sample->selectedItems ();
int itemsCount = testWidget->lw_props_sample->selectedItems ().count();
QStringList strings;
for (int i = 0; i < itemsCount; ++i)
{
strings.append(lw_temp.value(i)); // I am getting problem in this line. How to get the string value from the list and append it to QStringList
}
QApplication::clipboard()->setText(strings.join("\n"));
}
Error: error C2664: 'append' : cannot convert parameter 1 from 'class QListWidgetItem *' to 'const class QString &' at line:
Please help me...
thanks in Advance,
Prabhakar