Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. When i should/shouldnt i use QGraphicsView ?
Forum Updated to NodeBB v4.3 + New Features

When i should/shouldnt i use QGraphicsView ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 716 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Marcia3x
    wrote on last edited by Marcia3x
    #1

    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?

    JonBJ M 2 Replies Last reply
    0
    • M Marcia3x

      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?

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @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 to QGraphicsView?

      You talk all about "widgets" and "layouts" here. Why are you using/interested in widgets when you are using a graphics scene/view?

      M 1 Reply Last reply
      0
      • JonBJ JonB

        @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 to QGraphicsView?

        You talk all about "widgets" and "layouts" here. Why are you using/interested in widgets when you are using a graphics scene/view?

        M Offline
        M Offline
        Marcia3x
        wrote on last edited by
        #3

        @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.

        kkoehneK 1 Reply Last reply
        0
        • M Marcia3x

          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?

          M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          @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.

          1 Reply Last reply
          0
          • M Marcia3x

            @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.

            kkoehneK Offline
            kkoehneK Offline
            kkoehne
            Moderators
            wrote on last edited by
            #5

            @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.

            Director R&D, The Qt Company

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved