qtableview

Adding checkBox as vertical header in QtableView

会有一股神秘感。 提交于 2019-12-02 06:34:34
I am trying to have a QTableView of checkboxes, so I can use them for row selections... I have managed to do that, now I want the header Itself to be checkbox so I can check/Uncheck All or any row . I have been looking for days, but couldn't get to do it. I tried to use setHeaderData to the model, but couldn't do it. Any help would be appreciated. three_pineapples I wasn't particularly happy with the C++ version that @tmoreau ported to Python as it didn't: handle more than one column handle custom header heights (for example multi-line header text) use a tri-state checkbox work with sorting So

Select rows and columns in QTableWidget, while keeping highlighted

旧巷老猫 提交于 2019-12-02 05:02:36
I have a QTableWidget that I've set up such that you can't select the cells, but can select rows/columns by their headers. The problem I'm having is when I select a row, it deselects any columns that were selected, and same for column/rows. I want to be able to select rows with the ExtendedSelection behavior and columns with the SingleSelection behavior, but independently of eachother. Here's what I'm doing: ui->tableWidget->setSelectionMode(QAbstractItemView::NoSelection); connect(ui->tableWidget->horizontalHeader(),SIGNAL(sectionClicked(int)), this,SLOT(horizontalHeaderClicked(int)));

Finding index of a cell containing a value and highlighting all those cells in QTableView

随声附和 提交于 2019-12-02 04:47:05
问题 How can we find out the index (i.e both row and column numbers) of a cell containing a QString in a QTableView using QT c++? (P.S.:Without clicking on the cell in qtableview) 回答1: You can use findItems() function to find your cell. findItems() function returns a list of items that match the given text, using the given flags, in the given column. for (int index = 0; index < model->columnCount(); index++) { QList<QStandardItem*> foundLst = model->findItems("YourText", Qt::MatchExactly, index);

QTableView formatting numbers

陌路散爱 提交于 2019-12-02 03:19:05
I have created a delegate and i'm able to align and boldface the numbers on the table. I would like to force them to have two decimal places, for example 1.2 should show as 1.20. This is the header of the delagete: #ifndef TOTALDELEGATE_H #define TOTALDELEGATE_H #include <QObject> #include <QStyledItemDelegate> class TotalDelegate : public QStyledItemDelegate { public: TotalDelegate(); virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q_DECL_OVERRIDE; }; #endif // TOTALDELEGATE_H Here is the implementation: #include "totaldelegate.h"

QTableView formatting numbers

做~自己de王妃 提交于 2019-12-02 02:32:00
问题 I have created a delegate and i'm able to align and boldface the numbers on the table. I would like to force them to have two decimal places, for example 1.2 should show as 1.20. This is the header of the delagete: #ifndef TOTALDELEGATE_H #define TOTALDELEGATE_H #include <QObject> #include <QStyledItemDelegate> class TotalDelegate : public QStyledItemDelegate { public: TotalDelegate(); virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const Q

Finding index of a cell containing a value and highlighting all those cells in QTableView

大城市里の小女人 提交于 2019-12-02 01:42:17
How can we find out the index (i.e both row and column numbers) of a cell containing a QString in a QTableView using QT c++? (P.S.:Without clicking on the cell in qtableview) You can use findItems() function to find your cell. findItems() function returns a list of items that match the given text, using the given flags, in the given column. for (int index = 0; index < model->columnCount(); index++) { QList<QStandardItem*> foundLst = model->findItems("YourText", Qt::MatchExactly, index); } If you want to get index of found item and highlight it use this code: for (int index = 0; index < model-

Editable QTableView and Pandas do not work properly

丶灬走出姿态 提交于 2019-12-01 23:32:57
问题 I am trying to get a self-contained piece of example code for using pandas and QTableView while getting editable cell views. For this I am following up to an earlier discussion: Pandas df in editable QTableView: remove check boxes While the answer and proposed modifications in that other discussion help to get rid of the checkboxes, the code discussed there is still not working for me (python 2.7). When I modify a cell using the code below, the content shown in the cell is: PtQt4.PtCore

Editable QTableView and Pandas do not work properly

喜欢而已 提交于 2019-12-01 20:56:49
I am trying to get a self-contained piece of example code for using pandas and QTableView while getting editable cell views. For this I am following up to an earlier discussion: Pandas df in editable QTableView: remove check boxes While the answer and proposed modifications in that other discussion help to get rid of the checkboxes, the code discussed there is still not working for me (python 2.7). When I modify a cell using the code below, the content shown in the cell is: PtQt4.PtCore.QtVariant object at ... The package versions I use are: Pandas: 0.20.2 Pyside 1.2.4 Qt version: 4.8.4 SIP

How to change orientation of Qt TableView

痞子三分冷 提交于 2019-12-01 20:44:12
问题 Hi I am using a QTableView to display data from a sql table using the qsqltablemodel asfollows: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); model = new QSqlTableModel(this); model->setTable("staging"); model->select(); model->setHeaderData(0, Qt::Vertical, tr("ID")); model->setHeaderData(1, Qt::Vertical, tr("Region")); model->setHeaderData(2, Qt::Vertical, tr("T1")); model->setHeaderData(3, Qt::Vertical, tr("N1")); model-

How to change background color after editing QTableView cell?

半腔热情 提交于 2019-12-01 19:27:56
i have this QTableView with custom model and delegate, how do i change the background color of the cell after editing it? shall i do this in delegate's setModelData() ? index.model.setData(index, QVariant(True),Qt.UserRole) and later in model's data() # it's calling itself ? if role == Qt.BackgroundColorRole: if index.model().data(index,Qt.UserRole).toBool(): return QVariant(QColor(Qt.darkBlue)) and in model's setData() i don't have any code like: if role==Qt.UserRole: .... what is the correct way of doing this ? edit: Here is my whole setData() method in custom model def setData(self, index,