Results 1 to 6 of 6

Thread: errors in addressbook tutorial?

  1. #1
    Join Date
    Mar 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Question 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:


    Qt Code:
    1. if (dialog.exec()) {
    2. QString name = dialog.name();
    3. QString email = dialog.email();
    4. if (!name.isEmpty() && !email.isEmpty()) {
    5. QListWidgetItem *item = new QListWidgetItem(name, ui.addressList);
    6. item->setData(Qt::UserRole, email);
    7. ui.addressList->setCurrentItem(item);
    8. }
    9. }
    To copy to clipboard, switch view to plain text mode 
    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.
    Last edited by jpn; 13th March 2008 at 07:43. Reason: missing tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: errors in addressbook tutorial?

    Where is that tutorial exactly? Anyway just add #include <QListWidgetItem> and it should compile.

  3. #3
    Join Date
    Mar 2008
    Posts
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  4. #4
    Join Date
    Feb 2008
    Location
    Riverside, CA
    Posts
    18
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: errors in addressbook tutorial?

    Quote Originally Posted by Eolo View Post
    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: errors in addressbook tutorial?

    Quote Originally Posted by Eolo View Post
    I tried but it does not work.
    What exactly "does not work" mean in this case?

    Quote Originally Posted by Eolo View Post
    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.

  6. #6
    Join Date
    Apr 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default 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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.