Originally Posted by
aamer4yu
In the designer, double click on the QListWidget, you will get a dialog to add items.
Did you try it yet ?
Oh sorry! What I meant was if I could use the designer to build the item in the delegate. Right now I'm using the code below to create the delegate with QPainter as you can see. But I would like it if it was possible to create my ui in the designer instead and add my labels and so on.
Is that possible? And is there any examples of this?
if (option.
state & QStyle::State_Selected) { background = Qt::darkGray;
} else {
background = Qt::lightGray;
}
painter->fillRect(....
....
//More code here
....
painter->drawText(option.rect, Qt::AlignCenter, index.model()->data(index).toString());
}
void MyDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
QColor background;
if (option.state & QStyle::State_Selected) {
background = Qt::darkGray;
} else {
background = Qt::lightGray;
}
painter->fillRect(....
....
//More code here
....
painter->drawText(option.rect, Qt::AlignCenter, index.model()->data(index).toString());
}
To copy to clipboard, switch view to plain text mode
Bookmarks