QCategoryAxis Class
La clase QCategoryAxis coloca rangos nombrados en el eje. Más...
| Header: | #include <QCategoryAxis> |
| In QML: | CategoryAxis |
| Inherits: | QValueAxis |
Tipos Públicos
| enum | AxisLabelsPosition { AxisLabelsPositionCenter, AxisLabelsPositionOnValue } |
Propiedades
- categoriesLabels : QStringList
- count : int
- labelsPosition : AxisLabelsPosition
- startValue : qreal
Funciones públicas
| QCategoryAxis(QObject *parent = nullptr) | |
| virtual | ~QCategoryAxis() |
| void | append(const QString &categoryLabel, qreal categoryEndValue) |
| QStringList | categoriesLabels() |
| int | count() const |
| qreal | endValue(const QString &categoryLabel) const |
| QCategoryAxis::AxisLabelsPosition | labelsPosition() const |
| void | remove(const QString &categoryLabel) |
| void | replaceLabel(const QString &oldLabel, const QString &newLabel) |
| void | setLabelsPosition(QCategoryAxis::AxisLabelsPosition position) |
| void | setStartValue(qreal min) |
| qreal | startValue(const QString &categoryLabel = QString()) const |
Funciones públicas reimplementadas
| virtual QAbstractAxis::AxisType | type() const override |
Señales
| void | categoriesChanged() |
| void | labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position) |
Descripción detallada
Esta clase se puede utilizar para explicar los datos subyacentes añadiendo categorías etiquetadas. A diferencia de QBarCategoryAxis, QCategoryAxis permite especificar libremente las anchuras de los rangos de categorías.
Código de ejemplo sobre cómo utilizar QCategoryAxis:

QChartView *chartView = new QChartView; QLineSeries *series = new QLineSeries; // ... chartView->chart()->addSeries(series); QCategoryAxis *axisY = new QCategoryAxis; axisY->setMin(0); axisY->setMax(52); axisY->setStartValue(15); axisY->append("First", 20); axisY->append("Second", 37); axisY->append("Third", 52); chartView->chart()->setAxisY(axisY, series);
Documentación del tipo de miembro
enum QCategoryAxis::AxisLabelsPosition
Este enum describe la posición de las etiquetas de categoría.
| Constante | Valor | Descripción |
|---|---|---|
QCategoryAxis::AxisLabelsPositionCenter | 0x0 | Las etiquetas están centradas en la categoría. |
QCategoryAxis::AxisLabelsPositionOnValue | 0x1 | Las etiquetas se posicionan en el límite superior de la categoría. |
Documentación de la propiedad
[read-only] categoriesLabels : QStringList
Esta propiedad contiene las etiquetas de categoría como una lista de cadenas.
Funciones de acceso:
| QStringList | categoriesLabels() |
[read-only] count : int
Esta propiedad contiene el número de categorías.
Funciones de acceso:
| int | count() const |
labelsPosition : AxisLabelsPosition
Esta propiedad contiene la posición de las etiquetas de categoría. Las etiquetas del principio y del final de los ejes pueden solaparse con las etiquetas de otros ejes cuando se posicionan sobre el valor.
Funciones de acceso:
| QCategoryAxis::AxisLabelsPosition | labelsPosition() const |
| void | setLabelsPosition(QCategoryAxis::AxisLabelsPosition position) |
Señal del notificador:
| void | labelsPositionChanged(QCategoryAxis::AxisLabelsPosition position) |
startValue : qreal
Esta propiedad mantiene el extremo inferior de la primera categoría del eje.
Funciones de acceso:
| qreal | startValue(const QString &categoryLabel = QString()) const |
| void | setStartValue(qreal min) |
Documentación de funciones miembro
[explicit] QCategoryAxis::QCategoryAxis(QObject *parent = nullptr)
Construye un objeto eje hijo de parent.
[virtual noexcept] QCategoryAxis::~QCategoryAxis()
Destruye el objeto.
void QCategoryAxis::append(const QString &categoryLabel, qreal categoryEndValue)
Añade una nueva categoría al eje con la etiqueta categoryLabel. Una etiqueta de categoría debe ser única. categoryEndValue especifica el límite superior de la categoría. Debe ser mayor que el límite superior de la categoría anterior. De lo contrario, el método vuelve sin añadir una nueva categoría.
[signal] void QCategoryAxis::categoriesChanged()
Esta señal se emite cuando cambian las categorías del eje.
QStringList QCategoryAxis::categoriesLabels()
Devuelve la lista de etiquetas de las categorías.
Nota: Función Getter para la propiedad categoriesLabels.
int QCategoryAxis::count() const
Devuelve el número de categorías.
Nota: Función Getter para la propiedad count.
qreal QCategoryAxis::endValue(const QString &categoryLabel) const
Devuelve el límite superior de la categoría especificada por categoryLabel.
void QCategoryAxis::remove(const QString &categoryLabel)
Elimina del eje una categoría especificada por la etiqueta categoryLabel.
void QCategoryAxis::replaceLabel(const QString &oldLabel, const QString &newLabel)
Sustituye una etiqueta de categoría existente especificada por oldLabel por newLabel. Si la etiqueta antigua no existe, el método devuelve sin realizar ningún cambio.
void QCategoryAxis::setStartValue(qreal min)
Establece min como el límite inferior de la primera categoría del eje. Si ya se han añadido categorías al eje, el valor pasado debe ser menor que el valor del extremo superior del rango de la primera categoría ya definida. En caso contrario, no se hace nada.
Nota: Función Setter para la propiedad startValue.
Véase también startValue().
qreal QCategoryAxis::startValue(const QString &categoryLabel = QString()) const
Devuelve el límite inferior de la categoría especificada por categoryLabel.
Nota: Función Getter para la propiedad startValue.
Véase también setStartValue().
[override virtual] QAbstractAxis::AxisType QCategoryAxis::type() const
Reimplementa: QValueAxis::type() const.
Devuelve el tipo del eje.
© 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.