qabstracttablemodel

How to make QTableView refresh Background color after it loads data again

空扰寡人 提交于 2021-02-18 19:12:49
问题 i have the following doubt regarding QTableView , i have added some code that changes the row background depending on what string the dataframe contains on the last column. def data(self, index, role=Qt.DisplayRole): if index.isValid(): if role == Qt.BackgroundRole: if df.iloc[index.row(),5] == "Ready for QC": return QBrush(Qt.yellow) if df.iloc[index.row(),5] == "In Progress": return QBrush(Qt.green) if role == Qt.DisplayRole: return str(self._data.iloc[index.row(), index.column()]) return

How to make QTableView refresh Background color after it loads data again

只愿长相守 提交于 2021-02-18 19:09:12
问题 i have the following doubt regarding QTableView , i have added some code that changes the row background depending on what string the dataframe contains on the last column. def data(self, index, role=Qt.DisplayRole): if index.isValid(): if role == Qt.BackgroundRole: if df.iloc[index.row(),5] == "Ready for QC": return QBrush(Qt.yellow) if df.iloc[index.row(),5] == "In Progress": return QBrush(Qt.green) if role == Qt.DisplayRole: return str(self._data.iloc[index.row(), index.column()]) return

How to make QTableView refresh Background color after it loads data again

﹥>﹥吖頭↗ 提交于 2021-02-18 19:07:38
问题 i have the following doubt regarding QTableView , i have added some code that changes the row background depending on what string the dataframe contains on the last column. def data(self, index, role=Qt.DisplayRole): if index.isValid(): if role == Qt.BackgroundRole: if df.iloc[index.row(),5] == "Ready for QC": return QBrush(Qt.yellow) if df.iloc[index.row(),5] == "In Progress": return QBrush(Qt.green) if role == Qt.DisplayRole: return str(self._data.iloc[index.row(), index.column()]) return

With PySide2 and QTableView how do i get multiple delegates in table view using pandas model?

烈酒焚心 提交于 2021-01-28 08:40:39
问题 hi i've tried all i can think of and had looked at hundreds of stack overflow questions about tables and delegate's, and scratched my head for hours looking at the documentation trying to understand the c++ language and i have not read anything clearly stating that there's limits to the of amount delegate's a table view can take and not take, now i hope i can say i've got a firm understanding of the basic's in pyside2 and pyqt5 especially with tables and models but the delegates is a bit mind

How to insert QPushButton into TableView?

▼魔方 西西 提交于 2020-01-29 14:29:32
问题 I am implementing QAbstractTableModel and I would like to insert a QPushButton in the last column of each row. When users click on this button, a new window is shown with more information about this row. Do you have any idea how to insert the button? I know about delegating system but all examples are only about "how to edit color with the combo box"... 回答1: The model-view architecture isn't made to insert widgets into different cells, but you can draw the push button within the cell. The

Is there a generic TableModel we can use in JTables?

↘锁芯ラ 提交于 2020-01-03 01:22:28
问题 I'm now looking into JTables and have a bunch of business objects that I retrieve from the DB with Hibernate + Spring Data JPA. I love that Spring Data JPA handles all the cumbersome implementation of the DAL and was wondering if there's something similar for TableModel . Basically, I would have something along the lines of: public class GenericTableModel<T> extends AbstractTableModel And the GenericTableModel would use reflection and/or annotations to look into T . Does something like this

How to change the header background color of a QTableView

谁都会走 提交于 2019-12-23 08:18:46
问题 The following is what I've currently tried. The header text changes color correctly but the background will not change from the default. template<typename T> inline QVariant TableModel<T>::headerData(int section, Qt::Orientation orientation, int role) const { //... else if(role == Qt::BackgroundRole) { return QBrush(m_display.headerBackground); } //... } How can I set the background color? 回答1: You can set the style sheet on the QTableView ui->tableView->setStyleSheet("QHeaderView::section {

How to set row height of QTableView?

萝らか妹 提交于 2019-12-20 08:59:14
问题 I have QTableView and QAbstractTableModel . I require rows to have height equal to 24. I know the only way to do this is by calling QTableView::setRowHeight . Since the model is dynamic it may be added new rows, but I don't want to call setRowHeight each time new row is added. How can I configure QTableView such that it uses the same height for new added rows or can a model be sent the height of rows? 回答1: For Qt versions < 5 QHeaderView *verticalHeader = myTableView->verticalHeader();

How to change cell's background color of a QTableView [duplicate]

流过昼夜 提交于 2019-12-20 03:51:28
问题 This question already has answers here : background color of cells in QTableview, PySide2 (1 answer) PyQt Tableview background color based on text value rather than True or False (1 answer) Closed 6 months ago . I have a table view displaying a QAbstractTableModel, I managed to color a row within the data function but I just want to color the cell and not the entire row. i.e if the cell value = "In error" I want to color it in red I have tried to set a color to the cell using the setData

Understanding MVC in a QAbstractTableModel

半腔热情 提交于 2019-12-14 03:19:21
问题 I have some data which are represented by a class of my own ; to fix the ideas I give an example. class MyOwnModel(): def __init__(self, name="", number=0): self.name = name self.number = number I then have a list of such instances, that I want to represent in a QTableView . li = [MyOwnModel("a", 1), MyOwnModel("b", 2)] Then I see two strategies to make a QTableView from that : change MyOwnModel so that it subclasses QAbstractTableModel build a new QAbstractTableModel which mimics MyOwnModel