qstyleditemdelegate

What is the difference between QItemDelegate and QStyledItemDelegate?

别说谁变了你拦得住时间么 提交于 2019-12-09 14:38:41
问题 Both classes provide display and editing facilities for data items from a model. QStyledItemDelegate is newer and the Qt documentation about QItemDelegate states that : Note that QStyledItemDelegate has taken over the job of drawing Qt's item views. We recommend the use of QStyledItemDelegate when creating new delegates. I am confused what's the difference between the two and why QStyledItemDelegate is preferred over QItemDelegate ! 回答1: As mentioned in the QStyledItemDelegate documentation,

QStyledItemDelegate drawing custom widget failed

半城伤御伤魂 提交于 2019-12-07 12:56:11
问题 In one of my projects I'm using a QTableWidget in order to display some complex computational results. In order to increase the readability of the table I'm in need to display two aligned values inside of a single table cell. Later on I want to customize the widget even more by using colors or arrows etc.. For this I derived from QStyledItemDelegate and I called table ->setItemDelegate(new TwoNumbersDelegate) on my QTableWidget instance. For some reasons the QFrame is never display. I really

QTreeView with fixed column widths

邮差的信 提交于 2019-12-06 13:17:29
问题 Today I'm trying to configure a QTreeView to fit my requirements. My view has basically three columns. The second and third column should be exactly 50 pixels wide no matter, what might be widgets size. The first column should occupy the remaining space. If I enlarge my widget the first column should automatically occupy the need free space, whereas the second and third column should retain their given widths of 50 pixels. This is what I tried so far: main.cpp #include <QApplication> #include

QTreeView with fixed column widths

ⅰ亾dé卋堺 提交于 2019-12-04 19:48:18
Today I'm trying to configure a QTreeView to fit my requirements. My view has basically three columns. The second and third column should be exactly 50 pixels wide no matter, what might be widgets size. The first column should occupy the remaining space. If I enlarge my widget the first column should automatically occupy the need free space, whereas the second and third column should retain their given widths of 50 pixels. This is what I tried so far: main.cpp #include <QApplication> #include <QTreeView> #include <QDebug> #include <QStandardItemModel> #include <QHeaderView> #include

What is the parent of createEditor in a QStyledItemDelegate (PySide/PyQt/Qt)?

柔情痞子 提交于 2019-12-04 15:25:18
I have a QTreeView of a QStandardItemModel . I am painting/editing the data using a custom delegate. Within createEditor method, I use parent.window() to access the main window of the entire application (see below to link to some code from another question). Question: what is the parent of createEditor in the delegate? It is defined with the following parameters: def createEditor(self, parent, option, index) What is confusing is when QStyledItemDelegate is initialized, and I print type(parent) for that , I get the tree back (the tree that I have made this delegate to display). This is what I

Render QWidget in paint() method of QWidgetDelegate for a QListView

好久不见. 提交于 2019-11-30 02:08:12
i'm having difficulties implementing custom widget rendering in a QListView . I currently have a QListView displaying my custom model called PlayQueue based on QAbstractListModel . This is working fine with simple text, but now I would like to display a custom widget for each element. So I subclassed a QStyledItemDelegate to implement the paint method like this: void QueueableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if (option.state & QStyle::State_Selected) painter->fillRect(option.rect, option.palette.highlight()); QWidget

Render QWidget in paint() method of QWidgetDelegate for a QListView

戏子无情 提交于 2019-11-28 23:03:53
问题 i'm having difficulties implementing custom widget rendering in a QListView . I currently have a QListView displaying my custom model called PlayQueue based on QAbstractListModel . This is working fine with simple text, but now I would like to display a custom widget for each element. So I subclassed a QStyledItemDelegate to implement the paint method like this: void QueueableDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if (option