Please nominate your Qt Champions for 2021!

QGraphicsAnchorLayout Issues

  • I am using QT 4.8 with a QGraphicsAnchorLayout in a QGraphicsScene which is causing rendering issues. If I try to anchor two widgets to their Qt::AnchorVerticalCenter the horizontal borders on any sub-widgets get cut off. I am using it like so:

    layout.addAnchor(widgetA, Qt::AnchorVerticalCenter, widgetB, Qt::AnchorVerticalCenter);

    Any other combination of anchors works correctly, but when both widgets use the vertical center widgets get cut off. Is this a bug in QT or is there a way to work around it?

    Related to this, what is the easiest way to add pixel offsets to the anchors, do I need to use invisible graphics items as spacers, or is there a better way? I do not want to use the layout content margins or spacing because I do not want the offsets applied to the entire layout. Any help is appreciated.

Log in to reply