iwatsu
19th April 2011, 22:13
I have a delegate class that inherits from QStyledItemDelegate. In SlotDestroyed(): why is sender() of the type QPushButtonPrivate and not QPushButton?
QWidget *Delegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QPushButton *btn = new QPushButton(parent);
btn->setText("test");
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(SlotDestroyed(QObject*)));
return btn;
}
void Delegate::SlotDestroyed(QObject* editor)
{
QPushButton *btn = qobject_cast<QPushButton*>(sender()); // why null?
QObject *s = sender();
btn = reinterpret_cast<QPushButton*>(sender());
}
QWidget *Delegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QPushButton *btn = new QPushButton(parent);
btn->setText("test");
connect(btn, SIGNAL(destroyed(QObject*)), this, SLOT(SlotDestroyed(QObject*)));
return btn;
}
void Delegate::SlotDestroyed(QObject* editor)
{
QPushButton *btn = qobject_cast<QPushButton*>(sender()); // why null?
QObject *s = sender();
btn = reinterpret_cast<QPushButton*>(sender());
}