When i should/shouldnt i use QGraphicsView ?
-
I have a QWebEngineView which is inside the *QGridLayout of a QScrollArea, the scroll area contains 10+ widgets and buttons.
When I resize the scroll area the web engine is moved weirdly, looks like it only gets 'repositioned' in the grid, after all widgets have finished being repositioned.
Question:
I have never used QGraphicsView before, adding the scroll area containing all these widgets it could improve performance?QGraphicsView* view = new QGraphicsView(this); QGraphicsScene *scene = new QGraphicsScene(); view->setScene(scene); QGridLayout* layout = new QGridLayout(); view->setLayout(layout); layout->addWidget(ui.scrollArea);
Or do I need to add each widget individually to the scene?
Question2:
When is not recommended to use it? -
I have a QWebEngineView which is inside the *QGridLayout of a QScrollArea, the scroll area contains 10+ widgets and buttons.
When I resize the scroll area the web engine is moved weirdly, looks like it only gets 'repositioned' in the grid, after all widgets have finished being repositioned.
Question:
I have never used QGraphicsView before, adding the scroll area containing all these widgets it could improve performance?QGraphicsView* view = new QGraphicsView(this); QGraphicsScene *scene = new QGraphicsScene(); view->setScene(scene); QGridLayout* layout = new QGridLayout(); view->setLayout(layout); layout->addWidget(ui.scrollArea);
Or do I need to add each widget individually to the scene?
Question2:
When is not recommended to use it?@Marcia3x said in When i should/shouldnt i use QGraphicsView ?:
I have a QWebEngineView which is inside the *QGridLayout of a QScrollArea
Do you indeed mean
QWebEngineView
here? What is the relationship toQGraphicsView
?You talk all about "widgets" and "layouts" here. Why are you using/interested in widgets when you are using a graphics scene/view?
-
@Marcia3x said in When i should/shouldnt i use QGraphicsView ?:
I have a QWebEngineView which is inside the *QGridLayout of a QScrollArea
Do you indeed mean
QWebEngineView
here? What is the relationship toQGraphicsView
?You talk all about "widgets" and "layouts" here. Why are you using/interested in widgets when you are using a graphics scene/view?
@JonB said in When i should/shouldnt i use QGraphicsView ?:
Do you indeed mean QWebEngineView here?
Yes, QWebEngineView, I'm rendering a widget that is on a website on it, why?
What is the relationship to QGraphicsView?
I don't understand what QGraphicsView is used for, and this is what I'm currently asking...
If is possible to render the QWebEngineView and other widgets in the QGraphicsView, and if doing such a thing
could improve performance. -
I have a QWebEngineView which is inside the *QGridLayout of a QScrollArea, the scroll area contains 10+ widgets and buttons.
When I resize the scroll area the web engine is moved weirdly, looks like it only gets 'repositioned' in the grid, after all widgets have finished being repositioned.
Question:
I have never used QGraphicsView before, adding the scroll area containing all these widgets it could improve performance?QGraphicsView* view = new QGraphicsView(this); QGraphicsScene *scene = new QGraphicsScene(); view->setScene(scene); QGridLayout* layout = new QGridLayout(); view->setLayout(layout); layout->addWidget(ui.scrollArea);
Or do I need to add each widget individually to the scene?
Question2:
When is not recommended to use it?@Marcia3x said in When i should/shouldnt i use QGraphicsView ?:
I have a QWebEngineView which is inside the *QGridLayout of a QScrollArea, the scroll area contains 10+ widgets and buttons.
The webview already has scrollbars.
Usually, extra buttons are put in a toolbar.Show a screenshot of your window.
-
@JonB said in When i should/shouldnt i use QGraphicsView ?:
Do you indeed mean QWebEngineView here?
Yes, QWebEngineView, I'm rendering a widget that is on a website on it, why?
What is the relationship to QGraphicsView?
I don't understand what QGraphicsView is used for, and this is what I'm currently asking...
If is possible to render the QWebEngineView and other widgets in the QGraphicsView, and if doing such a thing
could improve performance.@Marcia3x said in When i should/shouldnt i use QGraphicsView ?:
I don't understand what QGraphicsView is used for, and this is what I'm currently asking...
QGraphicsView is a framework for rendering 2d content that predates Qt Quick. Back then, everything was a Qt Widget, but writing custom widgets is actually not easy & rather heavy if you're talking about lots of items. Qt Graphics View Framework does allow for drawing a scene lightweight items that do scale well. So in a way it's a predecessor of Qt Quick (though there are also lots of differences, and there are still valid use cases where you want to use QGraphicsView, and not Qt Quick).
Note that 'View' is just a general term here. That GraphicsView and WebEngineView both use it doesn't mean that they are technically interconnected.
If is possible to render the QWebEngineView and other widgets in the QGraphicsView, and if doing such a thing
could improve performance.You might actually be able to do this, since GraphicsView does allow for embedding a widget inside the view... But there's no reason to believe this will be faster. On the contrary, it is another level of indirection.
When I resize the scroll area the web engine is moved weirdly, looks like it only gets 'repositioned' in the grid, after all widgets have finished being repositioned.
I think this is explained by WebEngineView being a rather heavy component, that also does rendering out of process. This is btw not only an issue with Qt ... check any contemporary browser, and resizing the main window isn't exactly smooth, at least for me.