qitemdelegate

Create PushButtons in QTableView with QStyledItemDelegate subclass

假装没事ソ 提交于 2020-03-18 08:54:52
问题 I have the exact same problem, but I will use the QTableView widget. I read this and was wondering if I can override the createEditor function to use for instance QFileDialog to get the new data. If this is possible, can anyone provide me with an example to implement such a subclass to QItemDelegate. And if not, can anyone provide me with an example to implement a subclass to QItemDelegate, witch can draw a button next to a QLineEdit to get the functionality here. Edit: Maybe this question is

How to center QPixmap while Painting it inside QItemDelegate of QListWidget

两盒软妹~` 提交于 2019-12-25 18:48:12
问题 I'm painting a QPixmap inside the QItemDelegate of QListWidget. Each QListWidgetItem is of different dimensions. Inside the void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) function of QItemDelegate, I want to paint QPixmap with center Alignment inside the QListWidgetItem. option.rect() gives the geometry of the item with which I can calculate the center position and paint accordingly, but I want to know the better approach for this alignment.Can

selected item of comboBox in custom Delegate from QTableView

萝らか妹 提交于 2019-12-24 02:28:08
问题 I use a custom delegate to display a column of comboBoxes in my QTableView. The values are the same for all the comboBoxes so it's not really the population part that gives me trouble. I want them to show as the selected item, some value that I can retrieve from a database. I have access to the database from the delegate, but in order to send my request, I need the row of the comboBox. So I guess my question is : how can you iterate over all the rows of the table and do some action from

Why pressing of “Tab” key emits only QEvent::ShortcutOverride event?

我的未来我决定 提交于 2019-12-18 13:23:14
问题 Background Hi guys. I've made a custom widget with QLineEdit and several QPushButtons to use it with custom item delegate: class LineEditor : public QWidget { public: explicit LineEditor(QWidget *parent = 0) : QWidget(parent) { setLayout(new QHBoxLayout); layout()->setContentsMargins(0, 0, 0, 0); layout()->setSpacing(0); QLineEdit *edit = new QLineEdit(this); layout()->addWidget(edit); layout()->addWidget(new QPushButton(this)); layout()->addWidget(new QPushButton(this)); setFocusProxy(edit);

How to use QitemDelegate with multiple proxy models stacked?

社会主义新天地 提交于 2019-12-13 03:47:08
问题 This question is related to this previous question: how to use QSortFilterProxyModel for filter a 2d array? i have been trying to stack several proxy model to display a 2d array of data into a qtableview. @eyllanesc provided a really cool solution to my question but it doesn't seem to be compatible with qitemdelegate. When i add it to his example the delegate doesnt display as expected. Without the proxy3 it does show correctly. import random import math from PyQt4 import QtCore, QtGui class

Crash when calling getOpenFileName from QItemDelegate's custom editor

╄→尐↘猪︶ㄣ 提交于 2019-12-12 01:44:28
问题 Prerequisites: I have a custom QItemDelegate which creates custom editor for treeview items. The editor consists of a QLineEdit and QToolButton. The button is used to open the file dialog for selecting the file and placing it's path into line edit. I use a call to QFileDialog::getOpenFileName to open the file dialog. The dialog is native Windows file dialog (this is important). When the editor is created the first time, everything works ok no matter how often I press that button. But after

PyQt - QCombobox in QTableview

自作多情 提交于 2019-12-11 15:16:23
问题 I am displaying data from an SQLite database in a QTableView using a QSqlTableModel. Letting the user edit this data works fine. However, for some columns I want to use QComboboxes instead of free text cells, to restrict the list of possible answers. I have found this SO answer and am trying to implement it on my model/view setting, but I'm running into problems (so this is a follow-up). Here's a full mini-example: #!/usr/bin/python3 # -*- coding: utf-8 -*- from PyQt5 import QtSql from PyQt5

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,

Formatting data in a QTableView

冷暖自知 提交于 2019-12-08 19:39:27
I'm using a custom delegate to display QDoubleSpinBoxes in a QTableView. Those spinboxes display their contents with two decimals. My problem is that I would like the QTableView to also display those numbers with two decimals while they are not being edited (at which point they are not in a QDoubleSpinBox). Or, rather, I would like to be able to specifiy a format for the QTableView's contents. I tried to subclass QStyledItemDelegate to override displayText, but for a strange reason it crashes. It works correctly if I simply subclass QItemDelegate. I'm using Qt 4.6.3, on Windows. I'm not really

Formatting data in a QTableView

泪湿孤枕 提交于 2019-12-08 06:58:27
问题 I'm using a custom delegate to display QDoubleSpinBoxes in a QTableView. Those spinboxes display their contents with two decimals. My problem is that I would like the QTableView to also display those numbers with two decimals while they are not being edited (at which point they are not in a QDoubleSpinBox). Or, rather, I would like to be able to specifiy a format for the QTableView's contents. I tried to subclass QStyledItemDelegate to override displayText, but for a strange reason it crashes