Thanks Mr stranz
yes..now i design the items using a relative position, and im able to introduce 2 line of text + design
what i want around them....It very intresting to design what i want.
The way i introduce text is the more general way, using model :
Customdelegate *ItemDel=new Customdelegate(ListW);//connect delegate to view
ListW->setItemDelegate(ItemDel);
ListW->setModel(Mod);
//Create and Add item1 to Mod
Item1->setData("ciao1",Qt::DisplayRole);
Mod->appendRow(Item1);
//Create and Add item2 to Mod
Item2->setData("ciao2",Qt::DisplayRole);
Mod->appendRow(Item2);
QListView *ListW= new QListView(window);
Customdelegate *ItemDel=new Customdelegate(ListW);//connect delegate to view
QStandardItemModel *Mod= new QStandardItemModel();//connect model to view
ListW->setItemDelegate(ItemDel);
ListW->setModel(Mod);
//Create and Add item1 to Mod
QStandardItem *Item1= new QStandardItem();
Item1->setData("ciao1",Qt::DisplayRole);
Mod->appendRow(Item1);
//Create and Add item2 to Mod
QStandardItem *Item2= new QStandardItem();
Item2->setData("ciao2",Qt::DisplayRole);
Mod->appendRow(Item2);
To copy to clipboard, switch view to plain text mode
and in the delegate paint(), i get them using index & role
QString headerText
= qvariant_cast<QString>
(index.
data(Qt
::DisplayRole));
.....
......
QString headerText = qvariant_cast<QString>(index.data(Qt::DisplayRole));
.....
......
To copy to clipboard, switch view to plain text mode
and all what i aspect is working.....2 label in 2 line + a big rectangle around....Beautiful.
My next question is:I want add button (for now to be simple, we dont speak about signal&slot)
My idea was to add buttons to -Mod-, create a custom- role-,and identify button in paint() via my role.
But i cant introduce any button in model.
Next idea is to design button in the paint(); but this means also that in future i need to connect signal&slot
at every paint..a lot of computation.
What is your suggestion ?
Thanks
Roberto
Bookmarks