DmitryNik
8th October 2011, 10:38
Hello!
I have a question which concerns models and items in models and probably a bit QVariant. The question is: why will not appear a picture after executing the code presented bellow?
QStandardItem *item2 = new QStandardItem;
QVariant v1;
QIcon ico(":/block.png");
v1.setValue(ico);
item2->setData(v1, Qt::DisplayRole);
model->setItem(0, 0, item2);
QTreeView *tv = new QTreeView;
tv->setModel(model);
tv->show();
And another question, which was born by my curiosity, is: Does QStandardItem class's method setData work only with primitive data, such strings, integers etc.? Does it depend on QVariant-class?
I have a question which concerns models and items in models and probably a bit QVariant. The question is: why will not appear a picture after executing the code presented bellow?
QStandardItem *item2 = new QStandardItem;
QVariant v1;
QIcon ico(":/block.png");
v1.setValue(ico);
item2->setData(v1, Qt::DisplayRole);
model->setItem(0, 0, item2);
QTreeView *tv = new QTreeView;
tv->setModel(model);
tv->show();
And another question, which was born by my curiosity, is: Does QStandardItem class's method setData work only with primitive data, such strings, integers etc.? Does it depend on QVariant-class?