qtablewidgetitem

Create a QTableWidgetItem with flags()

拈花ヽ惹草 提交于 2021-02-05 05:58:37
问题 I dont understand the Qt5 Documentation in the TableWidgetItem-Chapter. I cant get the right parameters to set my freshly created TableCell as editable. I've got this piece of code for i, item in enumerate(event_desc, start=0): print(i, item) key = QTableWidgetItem(list(event_desc)[i]) value = QTableWidgetItem(event_desc[item]) value.setFlags( * what's to insert here? * ) tw.insertRow(i) tw.setItem(i, 0, key) tw.setItem(i, 1, value) The first param should be *self, the 2nd one is named 'Union

Retrieving data from columns qtablewidget

Deadly 提交于 2020-01-03 02:53:18
问题 I want to have a tablewidget that will color some of the rows based on certain conditions and threshold. For example, if the data in one column reaches over 20, it will color the row where that 20 was. What i have only searches through the Qtablewidgetitem and it does not do what I want it to do. def setmydata(self): for n, key in enumerate(self.data): for m, item in enumerate(self.data[key]): newitem = QtGui.QTableWidgetItem(item) c = newitem.column() + 2 print c for items in item: if

How to catch mouse over event of QTableWidget item in pyqt?

流过昼夜 提交于 2020-01-01 07:20:52
问题 what I want to do is to change the color of a QTableWidget item, when I hover with the mouse over the item of my QTableWidget. 回答1: Firstly, the table widget needs to have mouse-tracking switched on to get the hover events. Secondly, we need to find some signals that tell us when the mouse enters and leaves the table cells, so that the background colours can be changed at the right times. The QTableWidget class has the cellEntered / itemEntered signals, but there is nothing for when the mouse

Filling some QTableWidgetItems with QString from file

99封情书 提交于 2019-12-25 17:34:15
问题 I'm trying to fill a QTableWidget from a file that was exported by my program, but when I try to set text to the table cells they just ignore me, nothing happens. void MainWindow::on_actionOpen_Project_triggered() { QString line, fileName; fileName = QFileDialog::getOpenFileName(this,tr("Open Project"), "", tr("Project Files (*.project)")); if(!fileName.isEmpty()){ QFile file(fileName); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; QTextStream in(&file); for(int i=0;i<ui-

Qt, How can I sort QTableWidget column if the cells are widgets

我只是一个虾纸丫 提交于 2019-12-25 01:36:16
问题 I have a QTableWidget , some columns are filled with text, some with numbers, these columns are fine to sort. But I also have a column with custom widgets, how should I enable sorting for these? My first thought was of course to overload the '<' method on the QTableWidgetItem , but there are no QTableWidgetItem . So what would be the best way to solve this? 回答1: QTableWidget is not ideal for this case, consider using QTableView . Anyway, I will show you how to sort a QProgressBar widget in a

Get the index of a QTableWidget row knowing its elements

我的梦境 提交于 2019-12-24 14:28:37
问题 [I'm using PyQt4, but I think this Qt4 issue is not Python specific.] I have a QTableWidget . In each row, the first column holds a button. When clicked, the row is removed. To remove the row, I use removeRow(int row) method, which takes as argument the index of the row. When connecting the signal, I can't know the index of the row because it might change in the meantime (for instance if the first row is removed, all row indexes are changed). The accepted answer here suggests to pass the

PySide/PyQt: 'TypeError: native Qt signal is not callable' when trying to use 'currentItemChanged' with QTableWidget

浪尽此生 提交于 2019-12-23 19:15:15
问题 I have a table with some data that I want to be able to edit through the QTableWidget . Upon trying to connect the currentItemChanged signal: self.QTableWidget.currentItemChanged(QTableWidgetItem,QTableWidgetItem).connect(self.editCell) I get the following error: 'TypeError: native Qt signal is not callable' I went looking in to the QtDesigner , where you can connect signals. I made a QTableWidget , and connected it to a label so that changing the currentItem hid the label. In the signal

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

QTableWidgetItem shrinking

随声附和 提交于 2019-12-12 04:23:18
问题 I have an issue usign QTableWidgetItem. I normally use the QTableWidget like this this->setItem(i, j, new QTableWidgetItem()); this->item(i, j)->setText(string); The column I'm writing to is narrow, only about 20px. I need to write 2 digits in there and from the definition I cannot resize the column. The problem is that once the text overlaps the column width, it totally disappears and only three dots (or even nothing) appear instead. Can I suppress this behavior? I dont mind if there will be

QTableWidget: different styles in *one* QTableWidgetItem?

人盡茶涼 提交于 2019-12-11 04:32:09
问题 Is it possible to have a two-line element in a cell (QTableWidgetItem) of a QTableWidget with different styles per line? I want to have the first line bold and the second line not bold. Or can I add two QTableWidgetItems in one cell? Do a cellspan somehow? Cheers Matthias 回答1: Simple way : Checkout the setCellWidget method of QTableWidget. If you replace the default widget with QTextEdit, you can get rich text formatting capability. Better way : Use a custom QStyledItemDelegate. You can see