I have a delegate class that inherits from QStyledItemDelegate. In SlotDestroyed(): why is sender() of the type QPushButtonPrivate and not QPushButton?
{
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? 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());
}
To copy to clipboard, switch view to plain text mode
Bookmarks