qstyleditemdelegate

QStyledItemDelegate truncates text horizontally and doesn't add a horizontal scroll bar

混江龙づ霸主 提交于 2021-01-28 19:08:29
问题 I got the following code, which I slightly modified, as an answer on how to use HTML formatted text in a QListWidget. main.ui <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>Dialog</class> <widget class="QDialog" name="Dialog"> <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>341</width> <height>161</height> </rect> </property> <property name="windowTitle"> <string>Dialog</string> </property> <widget class="QWidget" name="verticalLayoutWidget"> <property name=

QStyledItemDelegate to display QComboBox in QTableView

萝らか妹 提交于 2020-08-03 04:12:36
问题 I'm new to Python and PyQt5. I'm using QStyledItemDelegate to make one of the QTableView column consisting of only ComboBox. I managed to display the ComboBox but and I'm having trouble with its behavior. Problem 1: The ComboBox doesn't seems to commit changes to the model even though selection was changed. I used the export button to print out the list for checking purposes. Problem 2: When I add a new row to the table, the new row ComboBox selection keeps reverting back to the first

QStyledItemDelegate to display QComboBox in QTableView

独自空忆成欢 提交于 2020-08-03 04:12:27
问题 I'm new to Python and PyQt5. I'm using QStyledItemDelegate to make one of the QTableView column consisting of only ComboBox. I managed to display the ComboBox but and I'm having trouble with its behavior. Problem 1: The ComboBox doesn't seems to commit changes to the model even though selection was changed. I used the export button to print out the list for checking purposes. Problem 2: When I add a new row to the table, the new row ComboBox selection keeps reverting back to the first

Make item delegate in QTableView not transparent

◇◆丶佛笑我妖孽 提交于 2019-12-24 23:09:24
问题 I issued in problem with custom item delegate for QTableView. That problem is completely illustrated by that screenshoot: We can see item content behind item delegate editor. What is the best way to hide that content or make item delegate not transparent? (how I can get background color/brush for edited row?) 回答1: You need to let your editor to paint its own background by enabling the autofill background property: editor->setAutoFillBackground(true); 回答2: widget->setStyleSheet("background

drawing icons in a table with QStyledItemDelegate paint()

拈花ヽ惹草 提交于 2019-12-24 10:58:04
问题 I'm trying to implement a custom paint function for a QStyledItemDelegate subclass (QT4.8.2). I've reviewed the StarItemDelegate example, among others, and it appears to be pretty straightforward. The delegate is assigned to a column of the table that indicates the record state. Column items are editable, but not user editable. I've implemented the delegate subclass and have proven that it works, but can't seem to get it to draw a simple icon. The code for the paint function is: { painter-

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

橙三吉。 提交于 2019-12-21 21:19:45
问题 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

Delegate erasing text in QTreeView using QStandardItemModel

☆樱花仙子☆ 提交于 2019-12-11 18:12:46
问题 I'm having some difficulty adding a delegate to my QTreeView. I have added some QStandardItems through a model which works fine, but when I add the delegate, the text is erased and only the icons are visible. This is the code i'm using for my delegate: void SeqNavDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { if (index.column() == 0 && option.state & QStyle::State_Enabled) { const QIcon icon(QLatin1String(":/SeqNavMenu/images/green.png

Adjusting the selection behaviour of QStandardItem with QStyledItemDelegate

北战南征 提交于 2019-12-11 10:51:26
问题 I am using QStyledItemDelegate to style the items in my QTreeView . The roots of my treeview are not decorated. It's just a simple tree with relation similar to the one below: ColorBook1 Color1 Color2 ColorBook2 Color3 The parent and child are styled differently and selection on parent is disabled. I want to customise the selection behaviour in the child nodes so that the selection rectangle around the child would cover the entire row and not the text child alone. Current Behaviour: Desired

Set delegate for QTreeWidget header

前提是你 提交于 2019-12-11 07:57:27
问题 I need to set delegate for QTreeWidget header or make it working with HTML tags using other ways. I set a delegate for QTreeWidget items using ui->tree->setItemDelegate(delegate); and it works. But setting a delegate to the header does not work : ui->tree->header()->setItemDelegate(delegate); 回答1: It won't work and it's documented here http://qt-project.org/doc/qt-4.8/qheaderview.html#appearance Note: Each header renders the data for each section itself, and does not rely on a delegate. As a

How to make item view render rich (html) text in PyQt?

烂漫一生 提交于 2019-12-10 17:37:58
问题 I'm trying to translate code from this thread in python: import sys from PyQt4.QtCore import * from PyQt4.QtGui import * __data__ = [ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.", "Excepteur sint