- Qt 6.8
- Qt 3D
- C++ Classes
- Qt3DRender (Deprecated)
- QSortPolicy
- Qt 6.8.1 Reference Documentation

# QSortPolicy Class

class Qt3DRender::QSortPolicy

Provides storage for the sort types to be used. More...

Header: | `#include <QSortPolicy>`
CMake: | `find_package(Qt6 REQUIRED COMPONENTS 3drender)` `target_link_libraries(mytarget PRIVATE Qt6::3drender)`
qmake: | `QT += 3drender`
In QML: | SortPolicy
Inherits: | Qt3DRender::QFrameGraphNode
Status: | Deprecated

- List of all members, including inherited members

## Public Types

enum | SortType { StateChangeCost, BackToFront, Material, FrontToBack, Texture, Uniform }

## Properties

- sortTypes : QList<int>

## Public Functions

| QSortPolicy(Qt3DCore::QNode *parent = nullptr)
QList<Qt3DRender::QSortPolicy::SortType> | sortTypes() const
QList<int> | sortTypesInt() const

## Public Slots

void | setSortTypes(const QList<Qt3DRender::QSortPolicy::SortType> &sortTypes)
void | setSortTypes(const QList<int> &sortTypesInt)

## Signals

void | sortTypesChanged(const QList<Qt3DRender::QSortPolicy::SortType> &sortTypes)
void | sortTypesChanged(const QList<int> &sortTypes)

## Detailed Description

A Qt3DRender::QSortPolicy class stores the sorting type used by the FrameGraph. The sort types determine how drawable entities are sorted before drawing to determine the drawing order. When QSortPolicy is present in the FrameGraph, the sorting mechanism is determined by the sortTypes list. Multiple sort types can be used simultaneously. If QSortPolicy is not present in the FrameGraph, entities are drawn in the order they appear in the entity hierarchy.

## Member Type Documentation

### enum QSortPolicy::SortType

This enum type describes the available sort types.

Constant | Value | Description
--- | --- | ---
`Qt3DRender::QSortPolicy::StateChangeCost` | `(1 << 0)` | sort the objects so as to minimize the cost of changing from the currently rendered state
`Qt3DRender::QSortPolicy::BackToFront` | `(1 << 1)` | sort the objects from back to front based on inverted z order. More accurately, the sorting key is the z component of the projection of the camera-to-object-center vector onto the camera's view vector.
`Qt3DRender::QSortPolicy::Material` | `(1 << 2)` | sort the objects based on their material (shader) value.
`Qt3DRender::QSortPolicy::FrontToBack` | `(1 << 3)` | sort the objects from front to back. The opposite of BackToFront.
`Qt3DRender::QSortPolicy::Texture (since Qt 5.14)` | `(1 << 4)` | sort the objects to minimize texture changes.
`Qt3DRender::QSortPolicy::Uniform (since Qt 5.15)` | `(1 << 5)` | sort the objects to minimize uniform changes.

## Property Documentation

### sortTypes : QList<int>

Specifies the sorting types to be used.

Access functions:

QList<int> | sortTypesInt() const
void | setSortTypes(const QList<Qt3DRender::QSortPolicy::SortType> &sortTypes)
void | setSortTypes(const QList<int> &sortTypesInt)

Notifier signal:

void | sortTypesChanged(const QList<Qt3DRender::QSortPolicy::SortType> &sortTypes)
void | sortTypesChanged(const QList<int> &sortTypes)

## Member Function Documentation

### `[explicit]` QSortPolicy::QSortPolicy(Qt3DCore::QNode *parent = nullptr)

Constructs QSortPolicy with given parent.

### QList<Qt3DRender::QSortPolicy::SortType> QSortPolicy::sortTypes() const

Returns the current sort types in use

See also setSortTypes().