qtablewidget

Scrolling QTableWidget smoothly

孤街浪徒 提交于 2019-12-08 08:52:24
问题 I have a QTableWidget with custom Widgets. These widgets are big and fill almost the whole scroll area in height, so that only one row is visible. I can scroll with the mouse wheel or by dragging the scroll bar, but the row always jumps. Is there a way to configure the QTableWidget to smoothly scroll, without jumping? 回答1: Try to use this: view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel) From Qt documentation: enum ScrollMode { ScrollPerItem, ScrollPerPixel } verticalScrollMode

Adding horizontal slider to QTableWidget

[亡魂溺海] 提交于 2019-12-08 06:06:58
问题 I am trying to design something like a timeline view for my video player. I decided to use QTableWidget as the timeline since it suits my purpose. My widget looks like this: I want the green line to run through the widget when i click on play. Here is my MVCE example: //View.cpp View::View(QWidget* parent) : QGraphicsView(parent) { QGraphicsScene* scene = new QGraphicsScene(this); TableWidget* wgt = new TableWidget; scene->addWidget(wgt); QGraphicsLineItem* item = new QGraphicsLineItem(30, 12

superscript for QTableWidget header

爱⌒轻易说出口 提交于 2019-12-08 05:34:18
问题 I'm learning QT and have to design a table like this I need "m2" with "2" as superscript. Here is my code: ui.tableWidget->horizontalHeaderItem(0)->setText("Date"); ui.tableWidget->horizontalHeaderItem(0)->setBackgroundColor(QColor(217, 217, 217)); ui.tableWidget->horizontalHeaderItem(1)->setText("House address"); ui.tableWidget->horizontalHeaderItem(1)->setBackgroundColor(QColor(217, 217, 217)); ui.tableWidget->horizontalHeaderItem(2)->setText("Area \n [m\u00B2]"); ui.tableWidget-

QTableWidget Checkbox get state and location

和自甴很熟 提交于 2019-12-08 03:47:22
问题 How to get state of all checkbox and get row and column of checked? Onclick PushButton function. QTableWidget *t = ui->tableWidget; t->setRowCount(2); t->setColumnCount(2); QStringList tableHeader; tableHeader<<"item01"<<"item02"; t->setHorizontalHeaderLabels(tableHeader); for (int i = 0; i < t->rowCount(); i++) { for (int j = 0; j < t->columnCount(); j++) { QWidget *pWidget = new QWidget(); QHBoxLayout *pLayout = new QHBoxLayout(pWidget); QCheckBox *pCheckBox = new QCheckBox(); pLayout-

How to save PyQt -TableWdiget-Tabular Data in Python main file or SQL DB?

元气小坏坏 提交于 2019-12-08 03:34:55
问题 I am a civil engineering student developing a python gui based tool for engineering calculation.Since all the calculations are based on table as we does in the excel file, I wanted to know how to save a table data entered through GUI tableWidget? And how to perform the operations on multiple tables? 回答1: You can download xlsxwriter which is a python package for writing to ms excel. in this example, am using a push button which will be used to export the data from the table to ms excel. You

Disable user to click over QTableWidget

ε祈祈猫儿з 提交于 2019-12-07 23:29:08
问题 I have QTableWidget with CheckBoxes in some cells. I want to disable user to perform mouse click over the table cells (so he can't change checkBox state) for some time while I am using data from the table. I've tried table.setDisabled(1) but that disables whole table and I need scroll to be enabled. Any help would be appreciated. EDIT To be more precise: there could be up to 15x3000 cells in table, filled with text(editable), checkbox(checkable), svg graphic(opens other window when double

Resize Column Width QTableWidget

為{幸葍}努か 提交于 2019-12-07 20:08:22
问题 I have this widget created with QTableWidget: and I would like that the column of my table resize in order to occupy the entire width of the widget, while for the rows is ok as it is. I know there is a similar question like mine but I was not able to solve it in that way.. This is my code void MainWindow::createTable(int rows, int columns) { mainList = new QTableWidget; QStringList headerLabels; headerLabels << "Title" << "Director" << "Year" << "Counter" << "Rating"; mainList->setRowCount

Widget alignment in cell pyqt

若如初见. 提交于 2019-12-07 14:55:35
问题 I'm developing some tool in PyQT4 and Python 2.7 and I stuck in a little problem. I've 3 buttons in stored in widget and that widget is in cell in the table (QTableWidget). So my problem is that I can't align widget to top of cell and tool doesn't resize row height to defined in widget minimum/fixed height. Here is how it looks now with method resizeRowToContents. And I want something like this I did something similar with fixed row height but its not the way I want. 回答1: I solved this

superscript for QTableWidget header

浪尽此生 提交于 2019-12-07 11:16:23
I'm learning QT and have to design a table like this I need "m2" with "2" as superscript. Here is my code: ui.tableWidget->horizontalHeaderItem(0)->setText("Date"); ui.tableWidget->horizontalHeaderItem(0)->setBackgroundColor(QColor(217, 217, 217)); ui.tableWidget->horizontalHeaderItem(1)->setText("House address"); ui.tableWidget->horizontalHeaderItem(1)->setBackgroundColor(QColor(217, 217, 217)); ui.tableWidget->horizontalHeaderItem(2)->setText("Area \n [m\u00B2]"); ui.tableWidget->horizontalHeaderItem(2)->setBackgroundColor(QColor(217, 217, 217)); ui.tableWidget->horizontalHeaderItem(3)-

How to limit the selection in a QTableWidget

橙三吉。 提交于 2019-12-07 05:23:25
问题 How would I go about limiting the rows/columns selected in a QTableWidget? I need to force the user to use a contiguous selection (already done) to select exactly two columns and any amount of rows. Thanks! 回答1: You will probably have to do one of 2 things: You would have to subclass QItemSelectionModel and implement functions for adding and deleting selected QModelIndex es so that you only add items from 2 rows to it. You can do this by having a custom implementation for catching signals