Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

color on q3dsurface only shows when zooming in



  • I've drawn a simple Q3DSurface. All seems to work OK, except the color only appears when I right click, mouse wheel zoom in, as close as I can to the surface. This is true for a solid color or a linear gradient. I've been through the Q3DSurface example line by line (the example works fine, I see the color immediately when I run the app) and I can't see anything significant that I think would cause this behavior. Can someone point out what I may be dong wrong? Note that the variable 'graph' is a Q3DSurface object.

    m_dataProxy = new QSurfaceDataProxy();
    m_dataSeries = new QSurface3DSeries(m_dataProxy);

    m_dataSeries->setDrawMode(QSurface3DSeries::DrawSurfaceAndWireframe);
    m_dataSeries->setFlatShadingEnabled(false);
    graph->addSeries(m_dataSeries);    
    
    QLinearGradient gr;
    gr.setColorAt(0.0, Qt::darkGreen);
    gr.setColorAt(0.5, Qt::yellow);
    gr.setColorAt(0.8, Qt::red);
    gr.setColorAt(1.0, Qt::darkRed);
    
    graph->activeTheme()->setType(Q3DTheme::ThemeQt);
    //graph->seriesList().at(0)->setBaseGradient(gr);
    //graph->seriesList().at(0)->setColorStyle(Q3DTheme::ColorStyleRangeGradient);
    
    QSurfaceDataArray *dataArray = new QSurfaceDataArray;
    dataArray->reserve(100);
    
    QSurfaceDataRow *tempRow1 = new QSurfaceDataRow(100);
    QSurfaceDataRow *tempRow2 = new QSurfaceDataRow(100);
    QSurfaceDataRow *tempRow3 = new QSurfaceDataRow(100);
    
    for (int i = 0 ; i < 100 ; i++)
    {
    (*tempRow1)[99-i].setPosition(QVector3D(i,1.0f,-50.0f));
    (*tempRow2)[99-i].setPosition(QVector3D(i,3.0f,0.0f));
    (*tempRow3)[99-i].setPosition(QVector3D(i,5.0f,50.0f));
    }
    
    *dataArray << tempRow1;
    *dataArray << tempRow2;
    *dataArray << tempRow3;
    
    m_dataProxy->resetArray(dataArray);
    
    graph->show();


  • @stevereine

    I solved my own problem, was drawing the graph in a Window, but not using a container to do it. It kind of works, but not very good. Always best to thoroughly understand the instructions before writing code. All is now working very well!


Log in to reply