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

How to set two color rectangle



  • Hello to everyone. How can I design a rectangle like in the image below with qml?

    alt text
    alt text


  • Moderators

    For the line:

    • use 2 rectangles (this is easy to do but impacts performance)
    • or make a custom QQuickItem and implement custom painting for it in updatePaintNode() (harder to do, no performance penalty)

    For the circle:

    • use QQuickPaintedItem item (easy but a bit slow)
    • or make a custom QQuickItem and implement custom painting for it in updatePaintNode() (harder to do, no performance penalty)
    • you can probably use Shapes QML module for this, too


  • Thank for reply @sierdzio . Your suggestions will do my job as a design. The colors that I will use to show these graphics may not be half and half, is there anything you can suggest for this?


  • Moderators

    All of my previous suggestion support the case when color rectangles are not equal. It's up to the implementation to handle it.


Log in to reply