qtablewidget

QT Inherit from QTableWidgetItem to Widget and overide '<' operator

混江龙づ霸主 提交于 2019-12-22 20:44:13
问题 I want a QTableWidget with certain cells as customized QProgressBar s, and I want it to be possible to sort the columns containing these. My customized QProgressBar is inheriting from both QProgressBar and QTableWidgetItem , and I am overiding the '<' operator to allow for sorting. Below is an example of a customized QTableWidget ( QTableWidget_custom ), QTableWidgetItem ( QTableWidgetItem_double ) and QProgressBar ( QProgressBar_custom ). After the table is populated, I am only able to sort

QTableWidget- automatic formula driven cell

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 04:35:00
问题 Is it possible to make one cell a formula driven cell and have it update automatically? Similar to Excel. For example, I want user to fill out two cells, and then a third cell will automatically divide when user fills both cells. I'd like it to be NOT connected to a button. QTable Screenshot Code for TableWidget: self.tableWidget = {} for i in range(int(self.numberLine.text())): self.tableWidget[i] = QTableWidget() self.tableWidget[i].setRowCount(5) self.tableWidget[i].setColumnCount(3) self

PyQt allign checkbox and put it in every row

会有一股神秘感。 提交于 2019-12-19 11:43:11
问题 I'm trying to do this with the check-box. Sadly is made for C++ and any adaptation of the code for Python has the result this error: 'QWidget' object is not callable What I wanna to do is to add a check-box on each row, this is my code: pWidget = QWidget() pCheckbox = QCheckBox() pLayout = QVBoxLayout() pLayout.addWidget(pCheckbox) pLayout.setAlignment(Qt.AlignCenter) pLayout.setContentsMargins(0, 0 ,0, 0) pWidget.setLayout(pLayout) for char in accounts: for columnNumber in range

Highlight search results in qtablewidget(select and highlight that text or character not all of the row or column)

妖精的绣舞 提交于 2019-12-17 17:23:08
问题 I use method1 to find some text in qtablewidget rows. method1 : def FindItem(self): items = self.SuraBRS.findItems( self.SearchTbox.text(), QtCore.Qt.MatchContains) if items: results = '\n'.join( 'row %d column %d' % (item.row() + 1, item.column() + 1) for item in items) else: results = 'Found Nothing' print(results) Now I want to know how to highlight results or change their color. I want to select and highlight that text or character not all of the row or column . 回答1: To be able to change

Custom Sorting in QTableWidget

妖精的绣舞 提交于 2019-12-14 02:17:38
问题 I have a QTableWidget and i am using its default sorting capability through header columns but one of my column in QTableWidget is integer type and through QTableWidget default sorting it is being sorted like a string.So there is any means by which i can use my own sorting functions for QTableWidget? 回答1: You can try to subclass the QTableWidgetItem and reimplement operator<() of it. Than in your QTableWidget use this custom items instead of default QTableWidgetItems. Something like this:

Qt table widget, button to delete row

巧了我就是萌 提交于 2019-12-13 14:03:02
问题 I have a QTableWidget and for all rows I set a setCellWidget at one column to a button. I would like to connect this button to a function that delets this row. I tried this code, which does not work, because if I simply click my button I do not set the current row to the row of the button. ui->tableWidget->insertRow(ui->tableWidget->rowCount()); QPushButton *b = new QPushButton("delete",this); ui->tableWidget->setCellWidget(ui->tableWidget->rowCount()-1,0,b); connect(d,SIGNAL(clicked(bool))

Move row up and down in PyQT4

拟墨画扇 提交于 2019-12-13 12:17:36
问题 Consider a QTableWidget and two buttons "move up" and "move down". Clicking on move up, the current row should move up one row, analogously for "move down". What's the easiest way to implement the corresponding move up and move down functions? 回答1: I have revised my answer because it did not have enough detail previously The process involves connecting your buttons to a slot (or slots) that will look at the current selection, and move them by taking them from the view, and inserting them into

more efficient solution for QTableWidget write

守給你的承諾、 提交于 2019-12-13 04:32:43
问题 I am reading a PyTable, with 1320000rows x 16cols The idea is to read the table and to write its content into a QTableWidget. The way I am doing it makes the GUI collapse. I would like a clue about how to do it in an efficient way. Here it is my code: #The PyTable is already opened and the reference to the desired table acquired self.ui.tableWidget.setRowCount(tab.nrows) self.ui.tableWidget.setColumnCount(len(tab.colnames)) self.ui.tableWidget.setHorizontalHeaderLabels(tab.colnames) res = []

QTableWidget find a row through userdata

牧云@^-^@ 提交于 2019-12-13 01:29:53
问题 QTableWidget have a method to search for a row with user data? Something like: //set user data row->setData(0, Qt::UserRole, "ID001"); //find row by user data int rowIndex = table->findByData("ID001"); 回答1: You can use QAbstractItemModel::match() QAbstractItemModel *model = table->model(); QModelIndexList matches = model->match( model->index(0,0), Qt::UserRole, "ID001" ) foreach( const QModelIndex &index, matches ) { QTableWidgetItem *item = table->item( index.row(), index.column() ) // Do

Qt model/view vs standard widget

戏子无情 提交于 2019-12-12 14:46:55
问题 I am currently reading model/view tutorial from Qt, but I am still not sure if I should use model/view or widget for my Qt program : I need to do a logger application that will monitor all information in a simulation environment. Basic scenario might be : User 1 say something to virtual entity B (logger application get what user 1 said and show it in table view or list view) Virtual entity B reply something to user 1 (logger application get what user 1 said and add it in table view or list