En esta página

QRhiViewport Class

Especifica un rectángulo de ventana gráfica. Más...

Encabezado: #include <rhi/qrhi.h>
CMake: find_package(Qt6 REQUIRED COMPONENTS GuiPrivate)
target_link_libraries(mytarget PRIVATE Qt6::GuiPrivate)
qmake: QT += gui-private
Desde: Qt 6.6

Funciones públicas

QRhiViewport()
QRhiViewport(float x, float y, float w, float h, float minDepth = 0.0f, float maxDepth = 1.0f)
float maxDepth() const
float minDepth() const
void setMaxDepth(float maxDepth)
void setMinDepth(float minDepth)
void setViewport(float x, float y, float w, float h)
std::array<float, 4> viewport() const
size_t qHash(const QRhiViewport &key, size_t seed = 0)
bool operator!=(const QRhiViewport &a, const QRhiViewport &b)
bool operator==(const QRhiViewport &a, const QRhiViewport &b)

Descripción detallada

Se utiliza con ` QRhiCommandBuffer::setViewport()`.

QRhi Asume coordenadas de ventana gráfica al estilo OpenGL, lo que significa que x e y se sitúan en la esquina inferior izquierda. No se permiten valores negativos para la anchura ni la altura.

El uso habitual es el siguiente:

const QSize outputSizeInPixels = swapchain->currentPixelSize();
const QRhiViewport viewport(0, 0, outputSizeInPixels.width(), outputSizeInPixels.height());
cb->beginPass(swapchain->currentFrameRenderTarget(), Qt::black, { 1.0f, 0 });
cb->setGraphicsPipeline(ps);
cb->setViewport(viewport);
// ...

Nota: Se trata de una API de RHI con garantías de compatibilidad limitadas; consulta QRhi para obtener más detalles.

Véase también QRhiCommandBuffer::setViewport(), QRhi::clipSpaceCorrMatrix() y QRhiScissor.

Documentación de las funciones miembro

[constexpr noexcept default] QRhiViewport::QRhiViewport()

Crea una descripción de la ventana gráfica con un rectángulo vacío y un rango de profundidad de 0,0f a 1,0f.

Véase también ` QRhi::clipSpaceCorrMatrix()`.

QRhiViewport::QRhiViewport(float x, float y, float w, float h, float minDepth = 0.0f, float maxDepth = 1.0f)

Crea una descripción de la ventana gráfica con el rectángulo especificado por x, y, w, h y el rango de profundidad minDepth y maxDepth.

Nota: Se supone quex y y corresponden a la posición inferior izquierda. w y h no deben ser valores negativos; de lo contrario, QRhiCommandBuffer::setViewport() ignorará la ventana gráfica.

Véase también QRhi::clipSpaceCorrMatrix().

float QRhiViewport::maxDepth() const

Devuelve el valor «maxDepth» del rango de profundidad de la ventana gráfica.

Véase también setMaxDepth().

float QRhiViewport::minDepth() const

Devuelve el valor «minDepth» del rango de profundidad de la ventana gráfica.

Véase también setMinDepth().

void QRhiViewport::setMaxDepth(float maxDepth)

Establece el valor de « maxDepth » del rango de profundidad de la ventana gráfica. Por defecto, este valor está fijado en 1.0f.

Véase también maxDepth().

void QRhiViewport::setMinDepth(float minDepth)

Establece la « minDepth » del rango de profundidad de la ventana gráfica. Por defecto, este valor está fijado en 0.0f.

Véase también minDepth().

void QRhiViewport::setViewport(float x, float y, float w, float h)

Establece la posición y el tamaño de la ventana de visualización en x, y, w y h.

Nota: Las ventanas gráficas se especifican en un sistema de coordenadas cuyo origen se encuentra en la esquina inferior izquierda.

Véase también viewport().

std::array<float, 4> QRhiViewport::viewport() const

Devuelve las coordenadas x e y, así como el ancho y la altura de la ventana gráfica.

Véase también setViewport().

Elementos no miembros relacionados

[noexcept] size_t qHash(const QRhiViewport &key, size_t seed = 0)

Devuelve el valor hash de key, utilizando seed como semilla para el cálculo.

[noexcept] bool operator!=(const QRhiViewport &a, const QRhiViewport &b)

Devuelve « false » si los valores de los dos objetos « QRhiViewport » — a y b — son iguales; en caso contrario, devuelve « true ».

[noexcept] bool operator==(const QRhiViewport &a, const QRhiViewport &b)

Devuelve « true » si los valores de los dos objetos « QRhiViewport » — a y b — son iguales.

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.