errors in addressbook tutorial?
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:
Code:
if (dialog.exec()) {
if (!name.isEmpty() && !email.isEmpty()) {
item->setData(Qt::UserRole, email);
ui.addressList->setCurrentItem(item);
}
}
to compile, I get the errors:
Quote:
`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.
Re: errors in addressbook tutorial?
Where is that tutorial exactly? Anyway just add #include <QListWidgetItem> and it should compile.
Re: errors in addressbook tutorial?
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
Re: errors in addressbook tutorial?
Quote:
Originally Posted by
Eolo
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.
Re: errors in addressbook tutorial?
Quote:
Originally Posted by
Eolo
I tried but it does not work.
What exactly "does not work" mean in this case?
Quote:
Originally Posted by
Eolo
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.
Re: errors in addressbook tutorial?
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. :)