daleotar
19th July 2011, 18:54
Hi.
I'm subclassing a QStyledItemDelegate in order to attach it to a QTableWidget.
It is working fine but I want to emit a signal from the delegate when I do some stuff inside the call of reimplemented QStyledItemDelegate::setEditorData, for instance:
class MyDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
MyDelegate(QObject* parent);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:
void mySignal(int value);
};
void MyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
int i = 1;
...do some stuff...
emit mySignal(i);
}
However I have a problem that I can't understand... The compiler is telling me:
"error: passing 'const MyDelegate' as 'this' argument of 'void MyDelegate::mySignal(int)' discards qualifiers"
I can't understand this error if I'm passing an int as an argument, not a "MyDelegate"...
If someone can explain or knows something about this or maybe, if anyone thinks that this is a bug...
Well, any help is appreciated...
I'm subclassing a QStyledItemDelegate in order to attach it to a QTableWidget.
It is working fine but I want to emit a signal from the delegate when I do some stuff inside the call of reimplemented QStyledItemDelegate::setEditorData, for instance:
class MyDelegate : public QStyledItemDelegate
{
Q_OBJECT
public:
MyDelegate(QObject* parent);
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
virtual void setEditorData(QWidget *editor, const QModelIndex &index) const;
virtual void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
virtual void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const;
signals:
void mySignal(int value);
};
void MyDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const
{
int i = 1;
...do some stuff...
emit mySignal(i);
}
However I have a problem that I can't understand... The compiler is telling me:
"error: passing 'const MyDelegate' as 'this' argument of 'void MyDelegate::mySignal(int)' discards qualifiers"
I can't understand this error if I'm passing an int as an argument, not a "MyDelegate"...
If someone can explain or knows something about this or maybe, if anyone thinks that this is a bug...
Well, any help is appreciated...