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 […]
Tag: qtableview
QTableView and QTableWidget use and override QTableView
1 Basic use of QTableView The main difference between the two is that QTableView can use a custom data model to display content (which means that you must first bind the data source through setModel before using it), while QTableWidget can only use a standard data model. Theoretically speaking, the functions implemented with QTableView can […]
Qt Programming-QTableView Freeze Rows or Freeze Columns or Freeze Partial Cells
Foreword Qt Programming-QTableView freezes rows or columns or freezes partial cells. Like the title, first check if the effect is what you need. The code snippets found online are either incomplete or not what you want. If you need the effect of freezing rows and columns at the same time, please read the next blog […]
Qt Programming-QTableView freezes rows and columns simultaneously
Foreword Qt Programming – QTableView freezes rows and columns simultaneously. Like the title, first check if the effect is what you need. The code snippets found online are either incomplete or not what you want. If you only need to freeze rows or columns, please read the previous blog Qt Programming-QTableView Freeze Rows or Freeze […]
Using various custom delegates in QTableView
QT’s MVC (View/Delegate) model is very powerful and can use various controls to limit table input. Idea: 1: Define delegates for each column: A: The first column is the number column. Use a read-only delegate to make the cells in this column read-only. B: The third column is the ID column. Only 1-12 numbers can […]
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 […]