The present slot's arguments must match the signal's arguments. So, you can't use a slot with FrameItem
parameter. Use this:
void itemClicked(QListWidgetItem* item) {
FrameItem* frameItem = static_cast<FrameItem*>(item);
//...
}
You need to cast QListWidgetItem
to FrameItem
. You're allowed to do this only if you are sure that it's really FrameItem
object. You can't use qobject_cast
since QListWidgetItem
doesn't inherit QObject
, but it's still better to use static_cast
instead of reinterpret_cast
. If you insert only FrameItem
items in your list, it would be OK. In other cases the perfect choice would be dynamic_cast
because it returns null pointer if the object is not actually FrameItem
. But it may not work if you use dynamic linking.
Aside of this, subclassing QListWidgetItem
is not recommended. As the documentation says, QListWidget::setItemWidget
should be used to display static content using custom Widgets, and QListView
and QItemDelegate
should be used in more complex cases.