qtablewidget

Adjust indents in QTableWidget cells and header items

风格不统一 提交于 2021-01-28 14:13:00
问题 I would like to align texts in a QTableWidget on the left side, but I would also like to add an indent so the text isn't stuck against the border. On the image, col_2 is what I want. And I would like the same for the header labels. from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QTableWidgetItem class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(400, 300) self.gridLayout = QtWidgets.QGridLayout(Form) self.gridLayout.setObjectName(

How should I connect CheckBox clicked signals in Table Widgets in PyQt5?

我的未来我决定 提交于 2021-01-27 21:08:51
问题 I would like to add various widgets to various cells in a Table Widget, and I would like to trigger commands when those widgets' values are changed. I can get the widgets into the table as desired, but I'm having problems connecting signals so that I know which widget has generated the signal. Below is a simple example explaining the problem, using just checkboxes: from PyQt5 import QtWidgets, QtGui, QtCore class Main(QtWidgets.QMainWindow): def __init__(self, parent=None): super().__init__

Row and column from “Itemchanged” signal

你说的曾经没有我的故事 提交于 2021-01-27 06:53:41
问题 I'm working with the "itemchanged" signal. How can I find out the row and column where the item was changed? I only found the same question for c++, but I'm using python. 回答1: The slot you connect to the itemChanged() signal receives a reference to the QTableWidgetItem that changed. You should be able to call the row() and column() functions of this object to determine the row/column. For example, the code to register your slot might look like this: self.imagesTable.itemChanged.connect(self

Crash in Deleting selected items from QTablewidget

和自甴很熟 提交于 2021-01-24 07:58:40
问题 I have a QTablewidget with the following settings tableWidget->setSelectionBehavior(QAbstractItemView::SelectRows); tableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection); I am trying to delete the user selected rows and use the following code. However, it results in a crash when all items are selected and deleted. Is the following approach correct ? Thanks. tableWidget->setSortingEnabled(false); QList<QTableWidgetItem *> selectedEntries = tableWidget->selectedItems(); foreach

How to highlight a words in QTableWidget from a Searchlist

青春壹個敷衍的年華 提交于 2021-01-19 06:56:35
问题 I want to search a QTableWidget-Table by a list of words, if they've been found i want them to bee highlighted. I tried to modify the code from here so the table is beeing searched by a list of words, not just one. Unfortunatly my results keep getting overwritten. I always only get the result for the last word in the list. Does anyone know how to modify the code so it will show the result of the whole list of words ? Here is the code: from PyQt5 import QtCore, QtGui, QtWidgets import random

Double right-click listener for a QTableWidget

为君一笑 提交于 2020-12-26 04:02:45
问题 I have a PyQt5 QTableWidget for which I want to detect double-right-click events. Here is my 'design.py' module: from PyQt5 import QtCore, QtWidgets class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(790, 472) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.tbwMain = QtWidgets.QTabWidget(self.centralwidget) self.tbwMain.setGeometry(QtCore.QRect(0, 0, 801, 451)) self

how can I clear a pyqt QTableWidget?

依然范特西╮ 提交于 2020-12-25 01:10:10
问题 I want to clear my QTableWidget. First of all I select a user in a qcombobox after that I click a qpushbutton and I populate it from database records; when I select other user and I click the qpushbutton to add data I try to clear with: self.tableFriends.clear() The data disappears but the rows remain. The code I populate with is: def getFriends(self): id_us = self.cbUser.itemData(self.cbUser.currentIndex()).toPyObject() rowIndex = 0 self.tableFriends.clear() for row in self.SELECT_FRIENDS(id

how can I clear a pyqt QTableWidget?

痴心易碎 提交于 2020-12-25 01:04:17
问题 I want to clear my QTableWidget. First of all I select a user in a qcombobox after that I click a qpushbutton and I populate it from database records; when I select other user and I click the qpushbutton to add data I try to clear with: self.tableFriends.clear() The data disappears but the rows remain. The code I populate with is: def getFriends(self): id_us = self.cbUser.itemData(self.cbUser.currentIndex()).toPyObject() rowIndex = 0 self.tableFriends.clear() for row in self.SELECT_FRIENDS(id

How to create a SIGNAL for QTableWidget from keyboard?

有些话、适合烂在心里 提交于 2020-12-12 06:27:32
问题 I have a table and move around inside with left, right, up, down buttons. Now I need to create a SIGNAL when I stay in a certain cell and press SPACE button. This SIGNAL should bring also the coordinate of that cell. I tried with standard signals of QTableWidget but it does not work. How can I solve this? 回答1: Create a separate header file i.e. "customtable.h" and then in the Designer you can Promote the existing QTableWidget to this class. class customTable:public QTableWidget { Q_OBJECT

How to create a SIGNAL for QTableWidget from keyboard?

非 Y 不嫁゛ 提交于 2020-12-12 06:24:05
问题 I have a table and move around inside with left, right, up, down buttons. Now I need to create a SIGNAL when I stay in a certain cell and press SPACE button. This SIGNAL should bring also the coordinate of that cell. I tried with standard signals of QTableWidget but it does not work. How can I solve this? 回答1: Create a separate header file i.e. "customtable.h" and then in the Designer you can Promote the existing QTableWidget to this class. class customTable:public QTableWidget { Q_OBJECT