yellowmat
7th February 2006, 14:23
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
#ifndef _ITEM_SELECTOR_H
#define _ITEM_SELECTOR_H
#include <qwidget.h>
#include <qvaluelist.h>
class QListBox;
class CItem;
class CItemSelector : public QWidget
{
Q_OBJECT
public:
// Constructor / Destructor
CItemSelector(QWidget* parent=0, const char* name=0);
// Slots
private slots:
void processItemSelectionChange(int);
public slots:
void updateHmi(QValueList<CItem>);
// Signals
signals:
void itemSelectionChanged(const CItem&);
// Members
private:
QListBox* lb;
QValueList<CItem> currentList;
};
#endif
and the .cpp
#include "itemselector.h"
#include <qlistbox.h>
#include ".\\..\\..\\item\\widgetsource\\item.h"
CItemSelector::CItemSelector(QWidget* parent, const char* name)
:QWidget(parent, name)
{
resize(300, 400);
// Create the list box
lb = new QListBox(this, "lb");
}
void CItemSelector::updateHmi(QValueList<CItem> list)
{
// Backup the list
currentList = list;
// Reset the content of the current list box
lb->clear();
// Fill the list box with the list items
QValueList<CItem>::iterator it;
for(it = list.begin(); it != list.end(); it++)
lb->insertItem(it.getItemName());
}
void CItemSelector::processItemSelectionChange(int value)
{
// Process something specific ... eventually
// TO DO
// Emit the signal
emit itemSelectionChanged(currentList[value]);
}
My compilation error message is the following
ItemSelector.cpp
..\WidgetSource\ItemSelector.cpp(26) : error C2039: 'getItemName' : is not a member of 'QValueListIterator<class CItem>
moc_ItemSelector.cpp
C:\Qt\3.3.3\include\qvaluelist.h(71) : error C2079: 'data' uses undefined class CItem
What does it mean ? How do I can fix my code ?
Thanks in advance.
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
#ifndef _ITEM_SELECTOR_H
#define _ITEM_SELECTOR_H
#include <qwidget.h>
#include <qvaluelist.h>
class QListBox;
class CItem;
class CItemSelector : public QWidget
{
Q_OBJECT
public:
// Constructor / Destructor
CItemSelector(QWidget* parent=0, const char* name=0);
// Slots
private slots:
void processItemSelectionChange(int);
public slots:
void updateHmi(QValueList<CItem>);
// Signals
signals:
void itemSelectionChanged(const CItem&);
// Members
private:
QListBox* lb;
QValueList<CItem> currentList;
};
#endif
and the .cpp
#include "itemselector.h"
#include <qlistbox.h>
#include ".\\..\\..\\item\\widgetsource\\item.h"
CItemSelector::CItemSelector(QWidget* parent, const char* name)
:QWidget(parent, name)
{
resize(300, 400);
// Create the list box
lb = new QListBox(this, "lb");
}
void CItemSelector::updateHmi(QValueList<CItem> list)
{
// Backup the list
currentList = list;
// Reset the content of the current list box
lb->clear();
// Fill the list box with the list items
QValueList<CItem>::iterator it;
for(it = list.begin(); it != list.end(); it++)
lb->insertItem(it.getItemName());
}
void CItemSelector::processItemSelectionChange(int value)
{
// Process something specific ... eventually
// TO DO
// Emit the signal
emit itemSelectionChanged(currentList[value]);
}
My compilation error message is the following
ItemSelector.cpp
..\WidgetSource\ItemSelector.cpp(26) : error C2039: 'getItemName' : is not a member of 'QValueListIterator<class CItem>
moc_ItemSelector.cpp
C:\Qt\3.3.3\include\qvaluelist.h(71) : error C2079: 'data' uses undefined class CItem
What does it mean ? How do I can fix my code ?
Thanks in advance.