PDA

View Full Version : Using qStyledItemDelegate to draw QTreeWidget items as QLabels



twooton
9th September 2010, 17:14
I've been pouring over examples of using qStyledItemDelegate for hours and I still haven't been able to find what I'm looking for. I just need a simple way to use QLabels for my items in QTreeWidget. Should I be using qStyledItemDelegate:: paint or the qTreeWidget::setItemWidget method? Can anybody point me in the right direction? Thanks

twooton
9th September 2010, 18:26
I think I could get it if I could figure out how to access the treeWidget from inside the paint function. That way I could just do a
QLabel *label = new QLabel();
label->setText("whatever");
ui->treeWidget->setItemWidget(item,0,label);


How would I do this? thanks in advance :)