R
R
roman_1234562022-03-08 22:39:45
Qt
roman_123456, 2022-03-08 22:39:45

Placing a QWidget on a QGraphicsView - what's the difference between the 2 approaches?

Good afternoon!

I want to place scene controls on QGraphicsView. Like these 6227adea0526f799884811.png
Controls should be stationary and not change scale when the view scale is changed.

Found 2 possible ways.
one.

QGraphicsView* view = new QGraphicsView;
MyWidget* mw = new MyWidget(view);


2.
QGraphicsScene* scene = new QGraphicsScene;
MyWidget* mw = new MyWidget(view);
QGraphicsProxyWidget* proxy = scene->addWidget(mw);
proxy->setFlag(QGraphicsItem::ItemIgnoresTransformations);


What are the pros and cons of the approaches? Which one should you choose?

Or to create such controls in general differently somehow?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question