Qt6 topics merged with General

Fill shape like paint bucket tool

  • Hello everyone:

    First of all thanks a lot for readint this post and being able to help.

    I have a scene with four lines which represent a square.

    I would like to fill the square in blue for example when I click inside the square with the mouse (like the paint tool "bucket").

    how can I do that?

    thanks a lot.

  • Lifetime Qt Champion


    One possibility would be to add a QGraphicsRectItem of the color you want in the desired quadrant.

    Another possibility would be to have a custom paint event that handles the four quadrants delimited by your lines.

    But first, what is the purpose of that scene ?

  • @SGaist Hello! thanks for replying!!

    In my scene I load somw lines which represent some squares or rectangles...
    So with a bucket tool I would like to fill these squares and rectangles just clicking inside them.

    Could you put a little example of code to help me please?

    thanks a lot

  • Lifetime Qt Champion

    How are you loading these lines ?

Log in to reply