我试图显示表格,使其所有行和列都在布局内。每个单元格的宽度或高度是否太小都无法键入。
这是一段代码,显示了我放置表格的布局以及显示表格的功能。
代码生成如下所示的图像:https://pastebin.com/29PjXAds
def createMainBody(self, MainWindow):
layout = QHBoxLayout()
self.generalLayout.addLayout(layout, 0, 0)
layout_mid = QVBoxLayout() # Layout the table is put into
self.binInfoTable = QTableWidget()
layout_mid.addWidget(self.binInfoTable)
layout.addLayout(layout_mid)
self.displayGraph(arr, color)
def displayGraph(self, graph_array, color_array):
a = np.array(graph_array)
# id, R, G, B
ca = np.array(color_array)
* TABLE CSS *
# Properities of the table
self.binInfoTable.showGrid()
self.binInfoTable.setRowCount(len(a))
self.binInfoTable.setColumnCount(len(a[0]))
self.binInfoTable.verticalHeader().setVisible(False)
self.binInfoTable.horizontalHeader().setVisible(False)
self.binInfoTable.verticalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.binInfoTable.horizontalHeader().setSectionResizeMode(QHeaderView.Stretch)
self.binInfoTable.resizeColumnsToContents()
* CODE TO FILL THE CELLS WITH COLOR *
我有什么:
我想要的: