Unsolved 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) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); scene = new QGraphicsScene(this); ui->graphicsView->setScene(scene); QBrush redBrush(Qt::red); QBrush blueBrush(Qt::blue); QPen blackPen(Qt::black); blackPen.setWidth(6); //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); rect->setFlag(QGraphicsItem::ItemIsSelectable,true); }
-
Hi
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
http://www.bogotobogo.com/Qt/Qt5_QGraphicsView_QGraphicsScene_QGraphicsItems.php -
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 :-)
-
Just as a note:
If you making any kind of Diagram / drawing app, this gives
a good start
http://doc.qt.io/qt-5/qtwidgets-graphicsview-diagramscene-example.html