QHeaderView is a class in the Qt GUI library that provides a header for a QTreeView or QTableView widget. The setSectionsMovable() function is used to toggle whether the user is allowed to rearrange the sections in the header.
Example 1: ```c++ #include
// create a QHeaderView QHeaderView* header = new QHeaderView(Qt::Orientation::Horizontal);
// allow sections to be moved by the user header->setSectionsMovable(true);
In this example, a QHeaderView object is created and the setSectionsMovable() function is called with the argument "true", allowing the user to move the sections.
Example 2:
c++
#include
#include
#include
// create a QStandardItemModel
QStandardItemModel* model = new QStandardItemModel(4, 2);
model->setHeaderData(0, Qt::Orientation::Horizontal, "Name");
model->setHeaderData(1, Qt::Orientation::Horizontal, "Age");
// create a QTableView and set the model
QTableView* tableView = new QTableView();
tableView->setModel(model);
// create a QHeaderView and set it as the horizontal header for the table view
QHeaderView* header = new QHeaderView(Qt::Orientation::Horizontal);
header->setSectionsMovable(true);
tableView->setHorizontalHeader(header);
```
In this example, a QTableView is created with a QStandardItemModel as its data source. A QHeaderView is also created and set as the horizontal header for the table view. The setSectionsMovable() function is called on the header to allow the user to move the sections. This code has dependencies on the QtCore and QtGui libraries.
C++ (Cpp) QHeaderView::setSectionsMovable - 17 examples found. These are the top rated real world C++ (Cpp) examples of QHeaderView::setSectionsMovable extracted from open source projects. You can rate examples to help us improve the quality of examples.