No, it's not derived...
here is a little bit of code:
{
Custom_Widget::Custom_Widget(QString name_par, QString date_par, QString about_par, QString picture_par, QWidget *parent)
: QWidget(parent)
{
imageLabel = new QLabel;
name = new QLabel(name_par);
To copy to clipboard, switch view to plain text mode
...
And some code i use to add custom widgets into my list Widget:
for (int i = 0; i<new_ml.size(); i++)
{
listWidget->insertItem(i, "");
listWidget->item(i)->setToolTip(new_ml[i]->name());
listWidget->setItemWidget(listWidget->item(i), new Custom_Widget
(new_ml[i]->name(), new_ml[i]->globalDate(), new_ml[i]->about(), new_ml[i]->picture()));
listWidget
->item
(i
)->setSizeHint
(QSize (350,
470));
listWidget->setSpacing(1);
}
for (int i = 0; i<new_ml.size(); i++)
{
listWidget->insertItem(i, "");
listWidget->item(i)->setToolTip(new_ml[i]->name());
listWidget->setItemWidget(listWidget->item(i), new Custom_Widget
(new_ml[i]->name(), new_ml[i]->globalDate(), new_ml[i]->about(), new_ml[i]->picture()));
listWidget->item(i)->setSizeHint(QSize (350,470));
listWidget->setSpacing(1);
}
To copy to clipboard, switch view to plain text mode
Added after 13 minutes:
Well.. i know why my previous cast wasn't working. I thought the (0) was the row on which the item was, but actually it wasn't. That's why i was getting wrong pointer, that is why my app was crashing... But I still have no idea how to use this cast properly...
Bookmarks