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. Why graphics scene occupy whole graphics view?

Why graphics scene occupy whole graphics view?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 478 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.
  • clostridium_difficileC Offline
    clostridium_difficileC Offline
    clostridium_difficile
    wrote on last edited by clostridium_difficile
    #1

    Why graphics scene is beeing drawed in whole graphics view area? I invoked setSceneRect and scene does not have correct size as it supposed to have.

    graphicsScene = std::make_shared<GraphicsScene>(new GraphicsScene(this));
    graphicsScene->setSceneRect(0, 0, 250, 250);
    graphicsScene->setBackgroundBrush(QColor(123,123,123));
    ui->canvas->setScene(graphicsScene.get());
    

    Whole view area is gray (color(123,123,123)) regardless what view's size is. Even graphics items are beeing drawed outside scene rect. How to correcty set scene size?

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      As that is how it works. The setSceneRect defines the logical extent of the scene and
      used by the View to know if to show scrollbars etc.
      Its not a setting for the ClientArea it will occupy. It will always fill the View completely.

      clostridium_difficileC 1 Reply Last reply
      1
      • clostridium_difficileC Offline
        clostridium_difficileC Offline
        clostridium_difficile
        wrote on last edited by
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • mrjjM mrjj

          Hi
          As that is how it works. The setSceneRect defines the logical extent of the scene and
          used by the View to know if to show scrollbars etc.
          Its not a setting for the ClientArea it will occupy. It will always fill the View completely.

          clostridium_difficileC Offline
          clostridium_difficileC Offline
          clostridium_difficile
          wrote on last edited by clostridium_difficile
          #4

          @mrjj said in Why graphics scene occupy whole graphics view?:

          Hi
          As that is how it works. The setSceneRect defines the logical extent of the scene and
          used by the View to know if to show scrollbars etc.
          Its not a setting for the ClientArea it will occupy. It will always fill the View completely.

          Well, how to make graphics view render only selected region of scene? Also, I have other questions: how to make scene to get events when mouse pointer is over scene's rendering rectangle?

          jsulmJ 1 Reply Last reply
          0
          • clostridium_difficileC clostridium_difficile

            @mrjj said in Why graphics scene occupy whole graphics view?:

            Hi
            As that is how it works. The setSceneRect defines the logical extent of the scene and
            used by the View to know if to show scrollbars etc.
            Its not a setting for the ClientArea it will occupy. It will always fill the View completely.

            Well, how to make graphics view render only selected region of scene? Also, I have other questions: how to make scene to get events when mouse pointer is over scene's rendering rectangle?

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @clostridium_difficile said in Why graphics scene occupy whole graphics view?:

            how to make scene to get events when mouse pointer is over scene's rendering rectangle?

            Override https://doc.qt.io/qt-5/qgraphicsscene.html#mouseMoveEvent

            https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            2

            • Login

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