qtablewidget

PyQt5 - Updating DataFrame behind QTableWidget

纵饮孤独 提交于 2019-12-11 06:05:30
问题 I am having problems with the Qt method to update a DataFrame if it has a specific element modified by the user in the GUI. For example, when I run the following code, I get a 10 by 3 DataFrame with random values displayed. If I try to change any cell to value 400, I double click, type 400 and then press enter. When I print the DataFrame, the value is still the old value. I would like the DataFrame cell to update on user changing the value. Many thanks! import sys import numpy as np import

How to hide vertical/horizontal lines in QTableWidget

て烟熏妆下的殇ゞ 提交于 2019-12-11 05:33:28
问题 I am using Pyqt4 for GUI programming in python. How can I hide vertical or horizontal lines in QTableWidget? 回答1: Try: yourTableWidget.setShowGrid(False) Unfortunately there seems to be no good way to do this via Stylesheets. A workaround is to set gridline-color: the same as background-color: . If you want to disable just vertical or horizontal lines, turn the grid off in code, and draw the borders per item with the QTableView::item selector. 来源: https://stackoverflow.com/questions/22455445

Python referencing database connection on another script

旧时模样 提交于 2019-12-11 05:32:43
问题 I'm in the depths of learning Python whilst trying to make an application, using data stored on a MySQL/MariaDB, and I am nearly at the stage that I can make some good progress with the project. I can connect to my DB via SSH, and retrieve data from a python script, but I am now looking to display that data in a GUI box. One of the challenges I'm facing is that I have two separate scripts to handle the connections, one to open and one to close, my theory being that a connection is only needed

How to detect QTableWidget scroll source (code itself/user (wheel)/user (scrollbar))?

流过昼夜 提交于 2019-12-11 05:21:32
问题 I'm writing a program using Qt 4.8 that displays a table (QTableWidget) filled with filenames and file's params. First an user adds files to the list and then clicks process. The code itself updates the contents of the table with simple progress description. I want the table by default to be scrolled automatically to show the last processed file and that code is ready. If I want to scroll it by hand the widget is being scrolled automatically as soon as something changes moving the viewport to

HowTo draw border for QTableWidget row?

♀尐吖头ヾ 提交于 2019-12-11 05:18:14
问题 I'm trying to make a border for rows in QTableWidget with different ways, but all solutions don't respond my requirements. All that I want, is to draw a rectangle around a whole row . I had try QStyledItemDelegate class, but that is not my way, because delegates are used only for item[ row, column ], not for the whole rows or columns. Here is wrong solution: /// @brief Рисуем границу вокруг строки. class DrawBorderDelegate : public QStyledItemDelegate { public: DrawBorderDelegate( QObject*

Add button to QTableWidget cell alongside with entry

让人想犯罪 __ 提交于 2019-12-11 04:39:37
问题 I have a QTableWidget and one column of it is for specifying file path. I want to provide user with two options, writing the path, or specifying it using QFileDialog . When I added a button as cell widget, it covered whole cell and the entry disappeared. QPushButton *browseButton = new QPushButton("...", tableWidget); tableWidget->setCellWidget(rowCount, 3, browseButton); How can I insert QPushButton or QAction with QIcon alongside with entry? 来源: https://stackoverflow.com/questions/16711404

QTableWidget: different styles in *one* QTableWidgetItem?

人盡茶涼 提交于 2019-12-11 04:32:09
问题 Is it possible to have a two-line element in a cell (QTableWidgetItem) of a QTableWidget with different styles per line? I want to have the first line bold and the second line not bold. Or can I add two QTableWidgetItems in one cell? Do a cellspan somehow? Cheers Matthias 回答1: Simple way : Checkout the setCellWidget method of QTableWidget. If you replace the default widget with QTextEdit, you can get rich text formatting capability. Better way : Use a custom QStyledItemDelegate. You can see

QTableView doesn't send expected FocusIn / FocusOut events to eventFilter

左心房为你撑大大i 提交于 2019-12-11 04:25:24
问题 I have a QTableWidget with floats or complex entries that need a lot of horizontal space. Displaying the values with reduced number of digits via string formatting works fine, but obviously I loose precision when editing and storing entries in the table. I have found a solution for QLineEdit widgets by using an eventFilter: A FocusIn event copies the stored value with full precision to the QLineEdit textfield, a FocusOut event or a Return_Key stores the changed value and overwrites the text

QTableWidget: Only numbers permitted

大城市里の小女人 提交于 2019-12-11 01:26:31
问题 Is there any way to disallow any characters except numbers (0-9) in a QTableWidget? For QLineEdits I'm using a RegEx validator, but this is not available for QTableWidgets. I thought of inserting QLineEdits in as CellWidgets into the table, but then I had to rewrite an extreme large amount of functions in my code. So, is there any other (direct) way to do so? 回答1: I would suggest using an item delegate for your table widget to handle the possible user input. Below is a simplified solution.

Retrieve value of QTableWidget cells which are QLineEdit widgets

夙愿已清 提交于 2019-12-11 00:49:46
问题 I create a QLineEdit,set a validator and put it on the table with this code: ui->moneyTableWidget->setCellWidget(rowsNum, 1, newQLineEdit); Then I've got another class for manipulating the table's data doing the sum of every value of a column. Here's the code: int Calculator::calculatePricesSum(QTableWidget &moneyTableWidget){ double total = 0; QWidget *tmpLineEdit; QString *tmpString; for(int row=0; row<moneyTableWidget.rowCount(); row++){ tmpLineEdit = (QLineEdit*)moneyTableWidget