qabstracttablemodel

How to insert QPushButton into TableView?

强颜欢笑 提交于 2019-12-01 07:41:31
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"... The model-view architecture isn't made to insert widgets into different cells, but you can draw the push button within the cell. The differences are: It will only be a drawing of a pushbutton Without extra work (perhaps quite a bit of extra

Qt Delete selected row in QTableView

给你一囗甜甜゛ 提交于 2019-12-01 04:18:40
I want to delete a selected row from the table when I click on the delete button. But I can't find anything regarding deleting rows in the Qt documentation. Any ideas? You can use the bool QAbstractItemModel::removeRow(int row, const QModelIndex & parent = QModelIndex()) functionality for this. Here you can find an example for all this. Also, here is an inline quote from that documentation: removeRows() Used to remove rows and the items of data they contain from all types of model. Implementations must call beginRemoveRows() before inserting new columns into any underlying data structures, and

Edit table in pyqt using QAbstractTableModel

孤街浪徒 提交于 2019-11-30 14:01:00
I'm trying to create an editable table in PyQt. Here's the code for just displaying the table: import sys from PyQt4 import QtGui, QtCore from PyQt4.QtCore import * from PyQt4.QtGui import * # données à représenter my_array = [['00','01','02'], ['10','11','12'], ['20','21','22']] def main(): app = QApplication(sys.argv) w = MyWindow() w.show() sys.exit(app.exec_()) # création de la vue et du conteneur class MyWindow(QWidget): def __init__(self, *args): QWidget.__init__(self, *args) tablemodel = MyTableModel(my_array, self) tableview = QTableView() tableview.setModel(tablemodel) layout =

Edit table in pyqt using QAbstractTableModel

余生长醉 提交于 2019-11-29 20:21:21
问题 I'm trying to create an editable table in PyQt. Here's the code for just displaying the table: import sys from PyQt4 import QtGui, QtCore from PyQt4.QtCore import * from PyQt4.QtGui import * # données à représenter my_array = [['00','01','02'], ['10','11','12'], ['20','21','22']] def main(): app = QApplication(sys.argv) w = MyWindow() w.show() sys.exit(app.exec_()) # création de la vue et du conteneur class MyWindow(QWidget): def __init__(self, *args): QWidget.__init__(self, *args) tablemodel

Qt QTableView how to have a checkbox only column

左心房为你撑大大i 提交于 2019-11-28 05:05:29
We are using a QTableView with Qt 4.6.3, and need a column that only has a checkbox in each cell. We're using a custom subclass of QAbstractTableModel as the model for the QTableView . Right now, we have a checkbox by setting the Qt::ItemIsUserCheckable flag. But we can't figure out how to get rid of the blank textbox next to the checkbox! How can we make the column only have a checkbox, nothing else? Here is a solution. For this to work properly, your column should not have the Qt::ItemIsEditable or Qt::ItemIsUserCheckable flags set. This reads the boolean values from Qt::DisplayRole and

Qt QTableView how to have a checkbox only column

≡放荡痞女 提交于 2019-11-27 05:26:24
问题 We are using a QTableView with Qt 4.6.3, and need a column that only has a checkbox in each cell. We're using a custom subclass of QAbstractTableModel as the model for the QTableView . Right now, we have a checkbox by setting the Qt::ItemIsUserCheckable flag. But we can't figure out how to get rid of the blank textbox next to the checkbox! How can we make the column only have a checkbox, nothing else? 回答1: Here is a solution. For this to work properly, your column should not have the Qt: