qtablewidget

Python GUI is not responding while thread is executing

拟墨画扇 提交于 2019-12-11 00:43:35
问题 I have Python GUI, and in one for-loop I call function from some dll which returns values for populating tableWidget row by row. All this works fine, except I can't scroll table while it's still populating (while dll function calculating things - 7-8secs for each row) so I tried work with threads like this: q = Queue.Queue() for i in (0, numberOfRows): threading.Thread(target=self.callFunctionFromDLL, args=(arg1,arg2, q)).start() result = q.get() ... do something with "result" and populate

How to disable selection highlighting in a QTableWidget

懵懂的女人 提交于 2019-12-10 21:13:20
问题 I have a QTableWidget with a disabled setSelectionMode (QTableWidget::NoSelection) and the QTableWidgetItems I fill in don't have the Qt::ItemIsEditable flag. Nevertheless, a cell that has been clicked gets some kind of cursor (the black line at the bottom in my case): How can I disable this "cursor"? 回答1: Does this help? QPalette palette = tableWidget->palette(); palette.setBrush(QPalette::Highlight,QBrush(Qt::white)); palette.setBrush(QPalette::HighlightedText,QBrush(Qt::black));

Spanning horizontal header in Qt

喜夏-厌秋 提交于 2019-12-09 18:34:14
问题 I want to merge(span) horizontal headers in QTableWidget . I tried googling for the same, but no luck and hence posting it. Please guide me. 回答1: You can subclass QHeaderView and create one section for each of the groups of columns/rows you would like to span and connect signals and slots to have them react to the different columns/rows. The following example is for spanning the horizontal header: #include <QtGui> class MyHeaderModel : public QAbstractItemModel { public: MyHeaderModel(QObject

Turn off PyQt Event Loop While Editing Table

不打扰是莪最后的温柔 提交于 2019-12-09 12:24:44
问题 I'm developing a GUI with PyQt. The GUI has a qListWidget, a qTableWidget, and a plot implemented with Mayavi. The list refers to shapes that are plotted (cylinders and cones for example). When a shape is selected in the list, I want the shape's properties to be loaded into the table (from a dictionary variable) and the shape to be highlighted in the plot. I've got the Mayavi plotting working fine. Also, if the table is edited, I need the shape to be re-plotted, to reflect the new property

Qt - How to associate data with QTableWidgetItem?

强颜欢笑 提交于 2019-12-09 11:13:45
问题 I want to associate additional data with each QTableWidgetItem inserted into the table, in order to use that data in future, when it is being clicked on a table item. But that data should not be visible. How can I do that? 回答1: You can use QTableWidgetItem::setData() like so: setData(Qt::UserRole, myData); // set Where myData is a supported QVariant type. You can use QTableWidgetItem::data() to retrieve the value that you store. If you need more than one you can use Qt::UserRole + 1, + 2, and

Scrolling QTableWidget smoothly

青春壹個敷衍的年華 提交于 2019-12-09 01:01:36
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? Try to use this: view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel) From Qt documentation: enum ScrollMode { ScrollPerItem, ScrollPerPixel } verticalScrollMode : ScrollMode This property holds how the view scrolls its contents in the vertical direction. This property

QTableWidget Checkbox get state and location

北战南征 提交于 2019-12-08 12:33:20
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->setAlignment(Qt::AlignCenter); pLayout->setContentsMargins(0,0,0,0); pLayout->addWidget(pCheckBox); pWidget

PyQt5 Qtablewidget and connecting to buttons

邮差的信 提交于 2019-12-08 12:13:03
问题 I have created a Qtablewidget as a class, and add_button to add rows, a delete_button to remove rows from table down upwards. I would like to connect functions to buttons, but it doesn't work correctly. I have used getattr method to call the function, still does not work. The table to explain more, those scriptlines are giving attributte errors. when they are called by button.clicked.connect method. add_button.clicked.connect(self._addrow) delete_button.clicked.connect(self._removeItem) The

How to know when the VerticalScrollBar is showing?

烈酒焚心 提交于 2019-12-08 11:59:06
问题 I need to know when the verticalScrollBar of my QTableWidget is being shown. I am currently using the following instruction: Header: #ifndef MYCLASS_H #define MYCLASS_H #include <QDebug> #include <QWidget> #include <QScrollBar> namespace Ui { class MyClass; } class MyClass: public QWidget { Q_OBJECT public: explicit MyClass(QWidget *parent = 0); ~MyClass(); private: void populateTable(QVector<QString> content); private: Ui::MyClass *ui; }; #endif // MYCLASS_H Populate table function: void

How to customize QTableWidget through stylesheet?

跟風遠走 提交于 2019-12-08 11:23:05
问题 I'm trying to customize a QTableWidget through stylesheet and I'm only limited to the items descibed here. How do I change the spacing in the horizontal header of the table, the size of its header label, the spaces between the columns, et al? 回答1: You should use QAbstractItemDelegate to control display of items in QTableWidget. From explanation of delegates: "Unlike the Model-View-Controller pattern, the model/view design does not include a completely separate component for managing