Important: Please read the Qt Code of Conduct -

Create a custom QBrush object from qml for custom chart

  • Hello, I'm currently designing a GUI with QML.
    I'm using ChartView to draw a chart and I want to customize its colors.

    I could change every color except the axis title, that needs the replace of a Brush and I can't create one.

    ValueAxis {               
        id: temp_y_axis       
        min: 0                
        max: 30               
        tickCount: 5          
        gridVisible: false    
        color: "white"        
        titleText: "Temp (ºC)"
        titleBrush:             /* wanted something like QBrush(Qt.white) here */
        labelFormat: "%d"     
        labelsFont.bold: true 
        labelsColor: "white"  

    I spent the whole day searching for ways to customize this, can anyone help me?

    Thanks in advance

  • Although this topic is too old , i will still mention that it's not possible to do this. Since QBrush may be not a subclass of qtobject. I would say that because i try to use qmlRegisterType() to register QBrush to qml engine. But when i create a instance i will get error below

    C:\Qt\5.15.2\mingw81_64\include\QtQml\qqmlprivate.h:71: error: 'staticMetaObject' is not a member of 'QBrush'

    You can modify the source code of chartview by adding color or other properties you need...

Log in to reply