qtablewidget

QTableWidget - Change the row color

故事扮演 提交于 2020-01-29 18:29:29
问题 I'm trying to change the color of background of an QTableWidget. There is some others posts about the same things bot nothing of the given solution worked for me. With that solution, we are setting the background on an alredy existed item in the table to a light grey on the item a row 0, column 1: self.table.item(1,0).setBackground(QtGui.QColor(125,125,125)) It's working, but set background for the row with iterating need more time if you have more then one table. I need a function to change

PyQt5 QTableWidget cell select, save and copy

て烟熏妆下的殇ゞ 提交于 2020-01-24 20:14:50
问题 As extension to my previous question I add a copy_button. When user enter input to cells, and user would like select a row, and click on copy_button to copy contents and add an new row below the selected row with same content. The code below supposes to do the job it adds a new row as user wants, expect from its contents is not copying with? I tried to print to see the problem. I add Qtablewidget items to empty list, then the list is printed before for loop, sees it has content added to it.

How can I show data on QTableWidget and read data from it with header?

五迷三道 提交于 2020-01-22 10:56:52
问题 How can I show data on QTableWidget and read data from it with header? 回答1: 1). Create table with this example code: filesTable = new QTableWidget(0, 2); QStringList labels; labels << tr("File Name") << tr("Size"); filesTable->setHorizontalHeaderLabels(labels); filesTable->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); filesTable->verticalHeader()->hide(); filesTable->setShowGrid(false); 2). Add row: int row = filesTable->rowCount(); filesTable->insertRow(row); filesTable-

Python - PyQt - QTable Widget - adding rows

ぐ巨炮叔叔 提交于 2020-01-13 08:21:31
问题 i am new to PyQt and still bit confused anyhow. I have a text file structure like this: Name Surname Telephone Email Where spaces are actually tabs " \t " now when i read this file whit my method i wish to populate the QTable Widget. My QTable Widget has 4 columns called Name , Surname , Telephone , Email now it has no rows but as I read lines from the file and split each line by tabulator I wish to add a new row that in each column contains whatever was in the line. Could someone point me in

Hide the border of the selected cell in qtablewidget in pyqt?

萝らか妹 提交于 2020-01-09 22:55:27
问题 Is there a way i can hide the border of the selected cell(or make the border color as white)in a qtablewidget.. By default a border with dotted line is shown.. Can u help me... 回答1: It looks like this dotted border around selected cell you're trying to hide is a focus rectangle. Any given cell can have focus and not be selected at the same time and vice-versa. If you want this border to not get painted use an item delegate. There you can remove State_HasFocus style from the item's state

How can I prevent transform cursor to SplitHCursor when it's under border between QHeaderView sections

天大地大妈咪最大 提交于 2020-01-07 09:28:11
问题 There are N columns with manual resizing width from left. Other columns widths are resizing only when columns with manual resizing are resizing. I need to prevent cursor icon changing when cursor is under borders of sections without manual resizing. What did I try to do. But this is work not very good. table_header_border.zip #include "mainwindow.h" #include "ui_mainwindow.h" const int N = 2; //============================================================================== int nWidth(const

PyQt5学习记录3-QTableWidget

旧街凉风 提交于 2020-01-06 21:42:30
QTableWidget是Qt程序中常用的显示数据表格的控件,类似于c#中的DataGrid。QTableWidget是QTableView的子类,它使用标准的数据模型,并且其单元数据是通过QTableWidgetItem对象来实现的,使用QTableWidget时就需要QTableWidgetItem。用来表示表格中的一个单元格,整个表格就是用各个单元格构建起来的 QTableWidget类中的常用方法 方法 描述 setROwCount(int row) 设置QTableWidget表格控件的行数 setColumnCount(int col) 设置QTableWidget表格控件的列数 setHorizontalHeaderLabels() 设置QTableWidget表格控件的水平标签 setVerticalHeaderLabels() 设置QTableWidget表格控件的垂直标签 setItem(int ,int ,QTableWidgetItem) 在QTableWidget表格控件的每个选项的单元控件内添加控件 horizontalHeader() 获得QTableWidget表格控件的表格头,以便执行隐藏 rowCount() 获得QTableWidget表格控件的行数 columnCount() 获得QTableWidget表格控件的列数

PyQt: How to catch mouse-over-event of QTableWidget-headers?

孤街醉人 提交于 2020-01-06 18:15:39
问题 what I want to do is to change the text of a QLable, everytime I hover with the mouse over the horizontalHeaders of my QTableWidget. How can I do that? Everytime I'm over a new header I need a signal and the index of the header. Hope someone of you has an idea. There must be a function, because if you hover over the headers, the background of the header changes. 回答1: Install an event filter that on the horizontalHeader() by using QObject.installEventFilter(): class HeaderViewFilter(QObject):

PyQt: How to catch mouse-over-event of QTableWidget-headers?

烈酒焚心 提交于 2020-01-06 18:13:10
问题 what I want to do is to change the text of a QLable, everytime I hover with the mouse over the horizontalHeaders of my QTableWidget. How can I do that? Everytime I'm over a new header I need a signal and the index of the header. Hope someone of you has an idea. There must be a function, because if you hover over the headers, the background of the header changes. 回答1: Install an event filter that on the horizontalHeader() by using QObject.installEventFilter(): class HeaderViewFilter(QObject):

How to insert my database into my QTableWidget table?

只愿长相守 提交于 2020-01-06 13:26:06
问题 class Table(QtGui.QDialog): def __init__(self, parent=None): super(Table, self).__init__(parent) layout = QtGui.QGridLayout() self.table = QtGui.QTableWidget() self.table.setRowCount(20) self.table.setColumnCount(3) layout.addWidget(self.table) self.enterDataInTable() self.setLayout(layout) def enterDataInTable(self): for row in range(0,20): for column in range(0,3): self.table.setItem(row, column, QtGui.QTableWidgetItem("cell %s-%s"%(row+1,column+1))) This code produces a table with 20 rows