Search code examples
qtopengl3dqt5qwidget

How to set the axis labels on Q3DSurface?


I tried to set axis labels on Q3DSurface by doing the following:

#include "mainwindow.h"

#include <Q3DSurface>

using namespace QtDataVisualization;

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
    Q3DSurface *graph = new Q3DSurface;
    QWidget *widget = QWidget::createWindowContainer(graph);
    setCentralWidget(widget);
    graph->axisX()->setLabels(QStringList{"a", "b", "c"});
}

MainWindow::~MainWindow() {}

But the labels are not showing, any hint on how to show them?

enter image description here


Solution

  • Setting this property for QValue3DAxis does nothing, as it generates labels automatically.

    https://doc.qt.io/qt-5/qabstract3daxis.html#labels-prop