qgraphicsitem border style

  • How can I draw a rectangle and oval shape like this.How to change there border style to double lines like this image.

    Widget::Widget(QWidget *parent) :
        ui(new Ui::Widget)
        scene = new QGraphicsScene(this);
        QBrush redBrush(Qt::red);
        QBrush blueBrush(Qt::blue);
        QPen blackPen(Qt::black);
        //rect = scene->addRect(25,25,Qt::RelativeSize);
        elipse = scene->addEllipse(20,20,100,100,blackPen,redBrush);
        elipse->setFlag(QGraphicsItem::ItemIsMovable, true);
        rect = scene->addRect(-20,-10,200,100,blackPen,blueBrush);
        rect->setFlag(QGraphicsItem::ItemIsMovable, true);

    alt text

  • Lifetime Qt Champion

    Not sure there is a setting for that.
    If you do not find something in the Docs then just create your own object and draw such border yourself using QPainter

  • I think you can subclass the graphics items you want to make appear like that. I have done it it is not difficult. You can see how to do it in the docs here.

    Other than that I would suggest drawing two items and put them in a group. Subclassing is much more elegant though :-)

  • Lifetime Qt Champion

    Just as a note:
    If you making any kind of Diagram / drawing app, this gives
    a good start

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.