Code: Alles auswählen
struct skill
{
public:
QString name;
int lvl;
};
int main()
{
.........
.........
QList<skill> skills;
skill temp;
temp.name = "Schwerter";
temp.lvl = 8;
skills.append(temp);
};
Code: Alles auswählen
struct skill
{
public:
QString name;
int lvl;
};
int main()
{
.........
.........
QList<skill> skills;
skill temp;
temp.name = "Schwerter";
temp.lvl = 8;
skills.append(temp);
};
Code: Alles auswählen
struct skill
{
QString name;
int lvl;
bool operator==(skill const& b) const
{
// Vergleich könnte auch anders erfolgen
return name == b.name && lvl == b.lvl;
}
};Code: Alles auswählen
struct skill
{
QString name;
int lvl;
bool operator==(skill const& b) const
{
return name == b.name && lvl == b.lvl;
}
};
int main()
{
if (!skilllist.contains("Schwerter"))
{
skill temp;
temp.name = "Schwerter"
temp.lvl = 1;
skilllist.append(temp);
};
};
Code: Alles auswählen
window.cpp:47: error: no matching function for call to `QList<skill>::contains(const char[10])'
f:/Qt/4.3.1/include/QtCore/../../src/corelib/tools/qlist.h:640: note: candidates are: QBool QList<T>::contains(const T&) const [with T = skill]Code: Alles auswählen
if (!skilllist.contains("Schwerter"))