qtablewidget

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

pyqt auto completion in a table

自闭症网瘾萝莉.ら 提交于 2019-12-24 15:57:08
问题 I need auto completion in a table. So far, I could make it work that I get the same list for the entire table. However, I need a dynamic list for each cell. How can I get update the list when I move to a new position in the cell? from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * import sys class mainWindow(QMainWindow): def __init__(self, parent = None): super(mainWindow, self).__init__(parent) self.initUI() def initUI(self): self.center_window = centerWindow

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

How do I implement the ability to edit a QTableWidget's vertical and horizontal header text in-line from the GUI instead of programmatically?

对着背影说爱祢 提交于 2019-12-24 10:48:18
问题 I have a QTableWidget that is displayed in the user interface that I can add and remove rows and columns using buttons. The problem is, when I add a row or column, I can change the data in the actual cells, but I cannot name the row or column. The name is simply a static number. Is there a way to allow the user of my program to perhaps double-click on a row/column header and edit the name in-line or something similar? Thanks. 回答1: As far as I know there is no built-in way to do this. However

Use QThread to periodically update a QTableWidget pyqt

女生的网名这么多〃 提交于 2019-12-24 00:23:32
问题 In my application, I'm fetching records using an API call and then I add the data to a QTableWidget dynamically. Here is a snippet of my code so far: class TriageUI(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) self.ui = Ui_TriageWindow() self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.move(QtGui.QApplication.desktop().screen().rect().center()- self.rect().center()) self.ui.setupUi(self) self.update_records() def update_records(self): #items are the results

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

How can I enable / disable QTableWidget's horizontal / vertical header?

喜你入骨 提交于 2019-12-23 07:35:24
问题 If I set the horizontalHeaderVisible or verticalHeaderVisible attribute to false in Qt Designer, this works fine. But how can I enable / disable headers in my code? I've been trying something like this: self.ui.tblContents.horizontalHeaderVisible = False 回答1: You'd get the header and .hide() (or .setVisible(False) : self.ui.tblContents.horizontalHeader().hide() # or # self.ui.tblContents.horizontalHeader().setVisible(False) self.ui.tblContents.verticalHeader().hide() # or # self.ui

Populating a table in PyQt with file attributes

喜你入骨 提交于 2019-12-23 04:47:38
问题 I'm trying to populate a QTableWidget with the attributes of a file opened elsewhere in the script. I've successfully set the file attributes read in from the file using the following code: class FileHeader(object): fileheader_fields=( "filetype","fileversion","numframes", "framerate","resolution","numbeams", "samplerate","samplesperchannel","receivergain", "windowstart","winlengthsindex","reverse", "serialnumber","date","idstring","ID1","ID2", "ID3","ID4","framestart","frameend","timelapse",

Qt: Different tableWidget member names on workstations

谁说我不能喝 提交于 2019-12-22 20:54:33
问题 I am using Qt on two ubuntu machines and am copying the source code from time to time between them. I found a really annoying problem when doing that and I can't figure out why this happens. I am using a table Widget to display some data and want to stretch the horizontal header to fit the content length. To do that I use the following line: ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); This works just fine. I have a few of this codelines. However, when

Qt: Different tableWidget member names on workstations

一个人想着一个人 提交于 2019-12-22 20:53:14
问题 I am using Qt on two ubuntu machines and am copying the source code from time to time between them. I found a really annoying problem when doing that and I can't figure out why this happens. I am using a table Widget to display some data and want to stretch the horizontal header to fit the content length. To do that I use the following line: ui->tableWidget->horizontalHeader()->setResizeMode(0, QHeaderView::ResizeToContents); This works just fine. I have a few of this codelines. However, when