Important: Please read the Qt Code of Conduct -

QGraphicsScene setSelectionArea Qt::ContainsItemShape

  • Hello,
    I want to add irregular selection mechanism to my application.
    Unfortunately passing QPainterPath with path containing only moveTo and lineTo don't select object that are enclosed inside shape that is created by such line (using select with Qt::ContainsItemShape). Adding to that QPainterPath polygon (path.addPolygon(path.toPoylgon()) and setting selection to Qt::IntersectsItemShape results with lines that are outside of selected area so it's not good option also but it do select items. If QPainterPath contains i.e. rectange that is larger then rectangle that I want to select also select object.

    How would I go about implementing selection of irregular shape? Or how to convert QPainterPath that do contains moveTo and lineTo to something that can be used with QGraphicsScene setSelectionArea.

    Also I think that tessellation of polygon with conjunction with IntersectsItemShape would solve the problem.

    Example of what I wand to achieve:
    Creating QPainterPath of shape that is on below image "doted" should select 2 rectangles:

Log in to reply