PDA

View Full Version : errors in addressbook tutorial?



Eolo
11th March 2008, 23:12
First, greetings to all. I just initiated in Qt 4.3.4. and I have been following the tutorial that accompanies the installation 'addressbook'. I have scrupulously followed all the steps but when I arrive while adding this code:



if (dialog.exec()) {
QString name = dialog.name();
QString email = dialog.email();
if (!name.isEmpty() && !email.isEmpty()) {
QListWidgetItem *item = new QListWidgetItem(name, ui.addressList);
item->setData(Qt::UserRole, email);
ui.addressList->setCurrentItem(item);
}
}

to compile, I get the errors:


`QListWidgetItem' undeclared (first use this function)
`QListWidgetItem' has not been declared
`item' undeclared (first use this function)

What is that? Do the tutorial has mistakes or I who is wrong? I appreciate any clarification to my question. Thanks.

jacek
11th March 2008, 23:18
Where is that tutorial exactly? Anyway just add #include <QListWidgetItem> and it should compile.

Eolo
12th March 2008, 08:34
Thank you for your reply. I tried but it does not work. The exact location of this tutorial is on eclipse/cheat sheets.../Qt Development/creating an address book application

brent99
12th March 2008, 17:45
First, greetings to all. I just initiated in Qt 4.3.4. and I have been following the tutorial that accompanies the installation 'addressbook'. I have scrupulously followed all the steps but when I arrive while adding this code:


if (dialog.exec()) {
QString name = dialog.name();
QString email = dialog.email();
if (!name.isEmpty() && !email.isEmpty()) {
QListWidgetItem *item = new QListWidgetItem(name, ui.addressList);
item->setData(Qt::UserRole, email);
ui.addressList->setCurrentItem(item);
}
}

to compile, I get the errors:

`QListWidgetItem' undeclared (first use this function)
`QListWidgetItem' has not been declared
`item' undeclared (first use this function)

What is that? Do the tutorial has mistakes or I who is wrong? I appreciate any clarification to my question. Thanks.

I don't know what your issue is here, but the tutorial works fine. Maybe not the best code in the world, but it should be functional.

jacek
13th March 2008, 00:23
I tried but it does not work.
What exactly "does not work" mean in this case?


The exact location of this tutorial is on eclipse/cheat sheets.../Qt Development/creating an address book application
I've never seen this tutorial and I don't have Eclipse integrations installed, so I'm not able to check it.

thezman
23rd April 2008, 21:39
Hi, I had the same error.

My problem was that I had dragged on a "List View" by mistake instead of a "List Widget".

Hope that works. :)