qtableview

How to proportionally adjust column widths in a QTableView?

廉价感情. 提交于 2021-02-04 19:38:08
问题 I want to proportionally change the column width of all columns in a QTableView widget, so that each column has the same width regardless of the data. For example, if a table has three columns, each column should always have a width of one third of the available horizontal space - and the width should be automatically updated whenever the dialog is resized by the user. So far I've only managed to resize columns to their contents, which is not what I want. Here's the code I've got so far: main

Qt - how to save my QTableView as a Excel File?

℡╲_俬逩灬. 提交于 2021-02-04 15:32:09
问题 Can anyone plz help me, how to save my QtableView as a Excel File. I have a QTableView and a QPushButton (Save Button). If i enter the values in my QtableView and if i click the Save Buttton the QTableView items should be saved as Excel File. Plz Help me. Thanks.. 回答1: Have a look at this thread My-approach-to-export-QTableView-data-to-a-Microsoft-Excel-file. I got this link by asking Google for: QTableView save. For the solution there you need a Qt with ODBC enabled which is not the default.

Making a specified table using pyqt5 designer

半腔热情 提交于 2021-01-29 03:57:34
问题 I want to make a specific table like shown in the picture below using pyqt designer and I coulnd't make a good result. I want to make this table in a window and contains the same elements and same dimensions. I tried to use layouts using LineEdits and Qlabels but I couldnt make it too . Thank you. 回答1: Premise: your question didn't show lots of research efforts, and from what was said it's quite clear that you're still a bit inexperienced; this will probably make this answer very complicated,

With PySide2 and QTableView how do i get multiple delegates in table view using pandas model?

烈酒焚心 提交于 2021-01-28 08:40:39
问题 hi i've tried all i can think of and had looked at hundreds of stack overflow questions about tables and delegate's, and scratched my head for hours looking at the documentation trying to understand the c++ language and i have not read anything clearly stating that there's limits to the of amount delegate's a table view can take and not take, now i hope i can say i've got a firm understanding of the basic's in pyside2 and pyqt5 especially with tables and models but the delegates is a bit mind

Changing the spacing between QTableView cells using stylesheet in PyQt5

喜夏-厌秋 提交于 2021-01-20 11:57:10
问题 How to add spaces between table cells using QSS selectors. I've tried the border-spacing selector, the item pseudo-class with the border selector, but it all doesn't work as it should. Here is a sample code that I thought was supposed to do this. app. setStyleSheet ("QTableView { border-collapse: separate; border-spacing: 10px 20px; color: red;}") Here's a picture of what I mean. 回答1: With style-sheets, you are either able to separate the individual cells via border-spacing (as in your

Cannot set header data with QTableView / custom table model

时间秒杀一切 提交于 2021-01-07 01:01:54
问题 I am on Maya / PySide2 / Python 2.7 I cannot set the header data with a custom table model. I tried this: from PySide2 import QtCore, QtGui, QtWidgets from PySide2.QtCore import Qt class TableModel(QtCore.QAbstractTableModel): def __init__(self, data): super(TableModel, self).__init__() self.setHeaderData(0, Qt.Horizontal, "Driver") self.setHeaderData(1, Qt.Horizontal, "Range") self.setHeaderData(2, Qt.Horizontal, "Driven") self.setHeaderData(3, Qt.Horizontal, "Range") self._data = data def

Cannot set header data with QTableView / custom table model

|▌冷眼眸甩不掉的悲伤 提交于 2021-01-07 00:58:25
问题 I am on Maya / PySide2 / Python 2.7 I cannot set the header data with a custom table model. I tried this: from PySide2 import QtCore, QtGui, QtWidgets from PySide2.QtCore import Qt class TableModel(QtCore.QAbstractTableModel): def __init__(self, data): super(TableModel, self).__init__() self.setHeaderData(0, Qt.Horizontal, "Driver") self.setHeaderData(1, Qt.Horizontal, "Range") self.setHeaderData(2, Qt.Horizontal, "Driven") self.setHeaderData(3, Qt.Horizontal, "Range") self._data = data def

How can you edit a QTableView cell from a QTest unit test?

可紊 提交于 2020-12-29 06:51:30
问题 I'm writing a unit test for a custom Validator in a QTableView using the QTestLib framework. One of the most basic test cases could be described like this: Double click the table cell in the third column and the fourth row, and append the number '5' to its content. It is not sufficient to simply change the value in the model or anything, the test case shall perform it like this: Double Click the table cell to set it into edit mode Press the [End] key. Press the [5] key. Note: This question

How can you edit a QTableView cell from a QTest unit test?

╄→尐↘猪︶ㄣ 提交于 2020-12-29 06:50:09
问题 I'm writing a unit test for a custom Validator in a QTableView using the QTestLib framework. One of the most basic test cases could be described like this: Double click the table cell in the third column and the fourth row, and append the number '5' to its content. It is not sufficient to simply change the value in the model or anything, the test case shall perform it like this: Double Click the table cell to set it into edit mode Press the [End] key. Press the [5] key. Note: This question

QTableView and double click on a cell

梦想的初衷 提交于 2020-12-06 03:34:27
问题 I am working on a test case editor. This editor contains USART a transmit and receive packet format. The editor is a table view. The transmit and receive packet is eight bytes long, for example: 0x01 0x02 0x03 ... 0x08 It is in my fifth and sixth column. Now, I want the cells in this column to be read only, but when I double-click on any cell in these columns a pop-up widget is displayed. This widget will contain eight boxes in the text edit, where the user can enter the packet format (i.e.