Hi everyone, I am not able to render a custom widget, like a QLabel in a QTreeView cell with a custom delegate. The delegate code is this:
*Header* #ifndef MESSAGESDELEGATE_H #define MESSAGESDELEGATE_H #include <QLabel> #include <QStyledItemDelegate> class MessagesDelegate : public QStyledItemDelegate { Q_OBJECT public: explicit MessagesDelegate(QObject* parent = nullptr); void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; private: mutable QLabel _label; }; #endif *Source* #include "MessagesDelegate.h" #include <QLabel> MessagesDelegate::MessagesDelegate(QObject* parent) : QStyledItemDelegate(parent) { } void MessagesDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const { _label.setText("This is a test message"); _label.render(painter); } and then: _messageDelegate = new MessagesDelegate(this); _messageTreeView->setItemDelegateForColumn(MessageColumn, _messageDelegate); But I am seeing my QTreeView cell empty instead of seeing the above "This a test message" in there. Do you know what I may be doing wrong? I took this idea from here: https://groups.google.com/g/python_inside_maya/c/FXB_V0llUpY/m/mpJOQkyJCgAJ Thank you in advance. Kind regards, László
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest