Use custom QSortFilterProxyModel to implement conditional filtering so that only row information that meets the conditions is displayed in qtableview

In actual development, qtableview is one of the most commonly used controls in Qt client pages. When using qtableview, the initial data will be filtered first, and then only the information that meets the conditions will be displayed on qtableview. Or display different row information that meets the conditions under different conditions. The first method […]

Qt QtableWidget, QtableView table deletes selected rows, deletes single rows, deletes multiple rows

Article directory Qt QtableWidget table delete selected rows Only one row can be selected. After clicking the button, a row will be deleted. You can select multiple rows and delete multiple rows after clicking the button Select different rows in a column and delete multiple rows after clicking the button Introduction to QTableWidgetSelectionRange QTableWidget selection […]

QSqlDatabase(2) instance, QTableView displays database table data

Table of Contents Preface 1. Functions implemented 2. Specific code implementation Foreword If you want to know the basic knowledge of QSqlDatabase and the usage of addition, deletion, modification and query, you can browse the previous article: QSqlDatabase (1) basic interface, and simple examples of (addition, deletion, and deletion)_Ivy_belief’s blog-CSDN blog This article is mainly […]

Use a proxy (QStyledItemDelegate) to add multiple button controls to each cell in a column or row of QTableView

OperationColumnDelegate.h #include <QStyledItemDelegate> #include <QPushButton> //The proxy class of the default interface class OperationColumnDelegate : public QStyledItemDelegate {<!– –> Q_OBJECT enum {<!– –> mouse_state_none = 0, mouse_state_hover, mouse_state_pressed, }; public: explicit OperationColumnDelegate(QObject *parent = nullptr); void paint(QPainter *painter, const QStyleOptionViewItem & amp;option, const QModelIndex & amp;index) const; bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem & […]

Qt model view framework: QTableWidget, QTableView, QListWidgetItem

QTableWidget 1. Description Standard form widget. Items in a QTableWidget are provided by QTableWidgetItem. How to use: tableWidget = new QTableWidget(12, 3, this); tableWidget = new QTableWidget(this); tableWidget->setRowCount(10); tableWidget->setColumnCount(5); or: QTableWidgetItem *newItem = new QTableWidgetItem(tr(“%1”).arg((row + 1)*(column + 1))); tableWidget->setItem(row, column, newItem); 2. Member functions 2.1. Signal 1. void cellActivated(int row, int column) This signal […]

Add a checkbox checkBox control to the table implemented by QtableView

1. The common method of adding check box checkBox control in the table implemented by QtableView. Method 1: Set the flags() function of QAbstractTableModel to implement. Features: direct display, definable style, default left alignment, it is difficult to achieve center and right alignment. Method 2: Customize the delegate QAbstractItemDelegate through the paint() function. Features: This […]