Qt-interest Archive, February 2008
ListWidgetItem editItem does not work
Message 1 in thread
Hello,
in a QListWidget I have some Items and want to edit them.
I thought that this would do the trick:
QListWidget * listSubjects = new QListWidget();
QListWidgetItem * lwI = new QListWidgetItem();
lwI = listSubjects->currentItem();
lwI->setFlags(Qt::ItemIsEditable);
i = lwI->flags();
listSubjects->editItem(lwI);
But the application just writes "edit failed" to the console.
What did I miss?
BR
Eckhard
--
[ signature omitted ]
Message 2 in thread
I think you forgot to mention the parent of the QListWidgetItem instance i.e.,
you declared the instance but didn't set it in the QListWidget
Also curentItem() returns the QListWidgetItem belonging to the current
QListWidget, and not set the set item into the listWidget.
use
QListWidgetItem * lwI = new QListWidgetItem(listSubjects, type);
>
to specify the parent while making the declaration, or use
listSubjects->insertItem(row, lwl);
>
after you have the set the flags as you desire.
Hope it should work :)
On Tue, Feb 26, 2008 at 2:20 PM, Eckhard Jokisch <e.jokisch@xxxxxxxxx>
wrote:
> Hello,
> in a QListWidget I have some Items and want to edit them.
> I thought that this would do the trick:
>
> QListWidget * listSubjects = new QListWidget();
> QListWidgetItem * lwI = new QListWidgetItem();
>
> lwI = listSubjects->currentItem();
> lwI->setFlags(Qt::ItemIsEditable);
> i = lwI->flags();
>
> listSubjects->editItem(lwI);
>
> But the application just writes "edit failed" to the console.
> What did I miss?
>
> BR
> Eckhard
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
Message 3 in thread
Hello,
yes thanks for the hints. It helped a lot. Furthermore I changed the setting
of the flags to
lwI->setFlags(lwI->flags() | Qt::ItemIsEditable);
which I found in the designer code but not in the examples or in the docs.
Now it works just perfect :))
BR
Eckhard
Gaurav Gupta wrote:
> I think you forgot to mention the parent of the QListWidgetItem instance
> i.e., you declared the instance but didn't set it in the QListWidget
>
> Also curentItem() returns the QListWidgetItem belonging to the current
> QListWidget, and not set the set item into the listWidget.
>
> use
>
> QListWidgetItem * lwI = new QListWidgetItem(listSubjects, type);
>>
>
> to specify the parent while making the declaration, or use
>
> listSubjects->insertItem(row, lwl);
>>
>
> after you have the set the flags as you desire.
>
> Hope it should work :)
>
> On Tue, Feb 26, 2008 at 2:20 PM, Eckhard Jokisch <e.jokisch@xxxxxxxxx>
> wrote:
>
>> Hello,
>> in a QListWidget I have some Items and want to edit them.
>> I thought that this would do the trick:
>>
>> QListWidget * listSubjects = new QListWidget();
>> QListWidgetItem * lwI = new QListWidgetItem();
>>
>> lwI = listSubjects->currentItem();
>> lwI->setFlags(Qt::ItemIsEditable);
>> i = lwI->flags();
>>
>> listSubjects->editItem(lwI);
>>
>> But the application just writes "edit failed" to the console.
>> What did I miss?
>>
>> BR
>> Eckhard
>>
>> --
>> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
>> "unsubscribe" in the subject or the body.
>> List archive and information: http://lists.trolltech.com/qt-interest/
>>
>>
--
[ signature omitted ]
Message 4 in thread
On Tuesday 26 February 2008 09:50:27 Eckhard Jokisch wrote:
> Hello,
> in a QListWidget I have some Items and want to edit them.
> I thought that this would do the trick:
>
> QListWidget * listSubjects = new QListWidget();
> QListWidgetItem * lwI = new QListWidgetItem();
>
> lwI = listSubjects->currentItem();
> lwI->setFlags(Qt::ItemIsEditable);
> i = lwI->flags();
>
> listSubjects->editItem(lwI);
>
Where do you assign the ListWidgetItem to the ListWidget?
> But the application just writes "edit failed" to the console.
> What did I miss?
>
> BR
> Eckhard
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/
--
[ signature omitted ]