Unsolved How modify the Q3DBars with multiple color bars?
-
I want to modify the "bars" in the QT example because I need that the bars are set with differents colors.
Any idea How to do that? -
@f-lerdino
Is that what you mean?
I also want to know how this is achieved. -
@f-lerdino if you want something like this:
there is code:QGuiApplication app (argc, argv); Q3DBars bars; bars.resize (800, 800); // Remove the frame for a borderless window bars.setFlags (bars.flags () ^ Qt::FramelessWindowHint); bars.rowAxis ()->setRange (0, 4); bars.columnAxis ()->setRange (0, 4); QBar3DSeries* series = new QBar3DSeries; // Set the color style for the series to ColorStyleRangeGradient series->setColorStyle (Q3DTheme::ColorStyleRangeGradient); // Define colors for the color style range gradient QLinearGradient gradient; gradient.setColorAt (0.0, Qt::green); gradient.setColorAt (0.5, Qt::yellow); gradient.setColorAt (1.0, Qt::red); // Create a data proxy for the series QBarDataProxy* dataProxy = new QBarDataProxy; // Create data items with values QBarDataRow* dataRow = new QBarDataRow; for (int i = 0; i < 5; ++i) { dataRow->append (QBarDataItem (1.0f * 0.1 * i)); } // Assign color style range gradient to the data proxy //dataProxy->setColorStyle (gradient); // Add data row to the data proxy dataProxy->addRow (dataRow); // Set data proxy for the series series->setDataProxy (dataProxy); series->setBaseGradient (gradient); bars.addSeries (series); bars.show (); return app.exec (); }
the key is "series->setColorStyle (Q3DTheme::ColorStyleRangeGradient);"