Results 1 to 3 of 3

Thread: Problem using QValueList

  1. #1
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Problem using QValueList

    Hi,

    I'm developping a class that looks like a list box and manage the displaying and scrolling of items (sound, image and color).

    I'm trying to use the QValueList Template but I have a compilation error and I don't know how to fix it. My code is inspired from Qt help but it does not works.

    Here is my .h
    Qt Code:
    1. #ifndef _ITEM_SELECTOR_H
    2. #define _ITEM_SELECTOR_H
    3.  
    4. #include <qwidget.h>
    5. #include <qvaluelist.h>
    6.  
    7. class QListBox;
    8. class CItem;
    9.  
    10. class CItemSelector : public QWidget
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. // Constructor / Destructor
    16. CItemSelector(QWidget* parent=0, const char* name=0);
    17.  
    18.  
    19. // Slots
    20. private slots:
    21. void processItemSelectionChange(int);
    22.  
    23. public slots:
    24. void updateHmi(QValueList<CItem>);
    25.  
    26.  
    27. // Signals
    28. signals:
    29. void itemSelectionChanged(const CItem&);
    30.  
    31. // Members
    32. private:
    33. QListBox* lb;
    34.  
    35. QValueList<CItem> currentList;
    36. };
    37.  
    38. #endif
    To copy to clipboard, switch view to plain text mode 

    and the .cpp
    Qt Code:
    1. #include "itemselector.h"
    2. #include <qlistbox.h>
    3. #include ".\\..\\..\\item\\widgetsource\\item.h"
    4.  
    5. CItemSelector::CItemSelector(QWidget* parent, const char* name)
    6. :QWidget(parent, name)
    7. {
    8. resize(300, 400);
    9.  
    10. // Create the list box
    11. lb = new QListBox(this, "lb");
    12. }
    13.  
    14.  
    15. void CItemSelector::updateHmi(QValueList<CItem> list)
    16. {
    17. // Backup the list
    18. currentList = list;
    19.  
    20. // Reset the content of the current list box
    21. lb->clear();
    22.  
    23. // Fill the list box with the list items
    24. QValueList<CItem>::iterator it;
    25. for(it = list.begin(); it != list.end(); it++)
    26. lb->insertItem(it.getItemName());
    27.  
    28. }
    29.  
    30.  
    31. void CItemSelector::processItemSelectionChange(int value)
    32. {
    33. // Process something specific ... eventually
    34. // TO DO
    35.  
    36. // Emit the signal
    37. emit itemSelectionChanged(currentList[value]);
    38. }
    To copy to clipboard, switch view to plain text mode 

    My compilation error message is the following
    Qt Code:
    1. ItemSelector.cpp
    2. ..\WidgetSource\ItemSelector.cpp(26) : error C2039: 'getItemName' : is not a member of 'QValueListIterator<class CItem>
    To copy to clipboard, switch view to plain text mode 
    Qt Code:
    1. moc_ItemSelector.cpp
    2. C:\Qt\3.3.3\include\qvaluelist.h(71) : error C2079: 'data' uses undefined class CItem
    To copy to clipboard, switch view to plain text mode 

    What does it mean ? How do I can fix my code ?

    Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Posts
    162
    Thanks
    9
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Problem using QValueList

    got it.

    I forget this line into the .h
    Qt Code:
    1. #include ".\\..\\..\\item\\WidgetSource\\item.h"
    To copy to clipboard, switch view to plain text mode 

    Now it works.

  3. #3
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Problem using QValueList

    Just a suggestion if I may:
    INCLUDEPATH += ..\..\item\widgetsource in your pro file
    #include <item.h> in your sources
    instead of: #include ".\\..\\..\\item\\WidgetSource\\item.h"

Similar Threads

  1. Problem in using QHttp with QTimer
    By Ferdous in forum Newbie
    Replies: 2
    Last Post: 6th September 2008, 12:48
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. problem with paint and erase in frame
    By M.A.M in forum Qt Programming
    Replies: 9
    Last Post: 4th May 2008, 20:17
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.