I am deriving a class from the QTableWidgetItem class as following.
#ifndef NUMBERITEM_H
#define NUMBERITEM_H
#include <QTableWidgetItem>
class NumberItem: public QTableWidgetItem
{
public:
using QTableWidgetItem::QTableWidgetItem;
bool operator < (const QTableWidgetItem &other) const
{
// TODO: To be safe, check weather conversion to int is possible.
return (this->text().toInt() < other.text().toInt());
}
};
#endif // ITEM_H
According to answers in this question I can inherit the base class (QTableWidgetItem) by using
keyword.But When I try to create a new NumberItem
object like below.
NumberItem *numberItem = new NumberItem("string_value");
it gives the following error
error: C2664: 'NumberItem::NumberItem(const NumberItem &)' : cannot convert parameter 1 from 'const char [13]' to 'const NumberItem &'
Reason: cannot convert from 'const char [13]' to 'const NumberItem'
No constructor could take the source type, or constructor overload resolution was ambiguous
How can I resolve this error?
Aucun commentaire:
Enregistrer un commentaire